-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added
/reward pulls
for server mods (#426)
* feat(utils/db): add script to reset player data * feat(commands): added `/reward pulls`
- Loading branch information
Showing
11 changed files
with
878 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Mongo } from '~/db/mod.ts'; | ||
|
||
if (import.meta.main) { | ||
// deno-lint-ignore no-non-null-assertion | ||
const db = new Mongo(Deno.env.get('MONGO_URI')!); | ||
|
||
const userId = '910124289372610560'; | ||
const guildId = '1288361915978092545'; | ||
|
||
const result1 = await db.characters().deleteMany({ | ||
userId, | ||
guildId, | ||
}); | ||
|
||
console.log(result1.deletedCount); | ||
|
||
const result2 = await db.inventories().deleteMany({ | ||
userId, | ||
guildId, | ||
}); | ||
|
||
console.log(result2.deletedCount); | ||
|
||
const result3 = await db.users().deleteMany({ | ||
discordId: userId, | ||
}); | ||
|
||
console.log(result3.deletedCount); | ||
|
||
await db.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import user from '~/src/user.ts'; | ||
|
||
import i18n from '~/src/i18n.ts'; | ||
|
||
import * as discord from '~/src/discord.ts'; | ||
|
||
import db from '~/db/mod.ts'; | ||
|
||
function pulls( | ||
{ userId, targetId, amount }: { | ||
userId: string; | ||
targetId: string; | ||
amount: number; | ||
}, | ||
): discord.Message { | ||
const locale = user.cachedUsers[userId]?.locale; | ||
|
||
const message = new discord.Message(); | ||
|
||
message.addEmbed( | ||
new discord.Embed() | ||
.setDescription( | ||
i18n.get( | ||
'admin-reward', | ||
locale, | ||
`<@${targetId}>`, | ||
amount, | ||
amount > 1 ? i18n.get('pulls', locale) : i18n.get('pull', locale), | ||
discord.emotes.add, | ||
), | ||
), | ||
); | ||
|
||
message.addComponents([ | ||
new discord.Component().setId( | ||
'reward', | ||
'pulls', | ||
userId, | ||
targetId, | ||
`${amount}`, | ||
) | ||
.setLabel(i18n.get('confirm', locale)), | ||
new discord.Component().setId('cancel', userId) | ||
.setStyle(discord.ButtonStyle.Red) | ||
.setLabel(i18n.get('cancel', locale)), | ||
]); | ||
|
||
return message; | ||
} | ||
|
||
async function confirmPulls({ userId, targetId, guildId, amount, token }: { | ||
userId: string; | ||
targetId: string; | ||
guildId: string; | ||
amount: number; | ||
token: string; | ||
}): Promise<discord.Message> { | ||
const locale = user.cachedUsers[userId]?.locale; | ||
|
||
await db.addPulls(targetId, guildId, amount, true); | ||
|
||
const message = new discord.Message(); | ||
|
||
message | ||
.addEmbed(new discord.Embed().setDescription( | ||
i18n.get( | ||
'rewarded-pulls', | ||
locale, | ||
`<@${targetId}>`, | ||
amount, | ||
amount > 1 ? i18n.get('pulls', locale) : i18n.get('pull', locale), | ||
discord.emotes.add, | ||
), | ||
)); | ||
|
||
const newMessage = new discord.Message().setContent(`<@${targetId}>`); | ||
|
||
newMessage | ||
.addEmbed(new discord.Embed().setDescription( | ||
i18n.get( | ||
'got-rewarded-pulls', | ||
locale, | ||
`<@${userId}>`, | ||
amount, | ||
amount > 1 ? i18n.get('pulls', locale) : i18n.get('pull', locale), | ||
discord.emotes.add, | ||
), | ||
)); | ||
|
||
message.patch(token).then(() => { | ||
newMessage.followup(token); | ||
}); | ||
|
||
return new discord.Message(); | ||
} | ||
|
||
const reward = { | ||
pulls, | ||
confirmPulls, | ||
}; | ||
|
||
export default reward; |
Oops, something went wrong.