mirror of
https://github.com/yuzu-emu/Command-fix
synced 2024-11-23 17:33:43 +00:00
commands/grantTester: new command
This commit is contained in:
parent
c61fafdca0
commit
7baa540663
2 changed files with 21 additions and 0 deletions
1
env.json
1
env.json
|
@ -33,6 +33,7 @@
|
||||||
"description": "The unique ID for the role that the bot will *remove* when the user accepts the rules."
|
"description": "The unique ID for the role that the bot will *remove* when the user accepts the rules."
|
||||||
},
|
},
|
||||||
"DISCORD_DEVELOPER_ROLE": true,
|
"DISCORD_DEVELOPER_ROLE": true,
|
||||||
|
"DISCORD_TESTER_ROLE": true,
|
||||||
"DISCORD_LOGIN_TOKEN": {
|
"DISCORD_LOGIN_TOKEN": {
|
||||||
"description": "The login token of the bot."
|
"description": "The login token of the bot."
|
||||||
},
|
},
|
||||||
|
|
20
src/commands/grantTester.ts
Normal file
20
src/commands/grantTester.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import logger from '../logging';
|
||||||
|
import * as discord from 'discord.js';
|
||||||
|
import { grantRole } from '../common';
|
||||||
|
|
||||||
|
const role = process.env.DISCORD_TESTER_ROLE;
|
||||||
|
|
||||||
|
export const roles = ['Admins', 'Moderators', 'CitraBot'];
|
||||||
|
export async function command (message: discord.Message) {
|
||||||
|
if (!role) {
|
||||||
|
logger.error('DISCORD_TESTER_ROLE suddenly became undefined?!');
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all(message.mentions.users.map(async (user) => {
|
||||||
|
return message.guild?.members.fetch(user).then((member) => grantRole(member, role, message.channel))
|
||||||
|
.catch(async () => {
|
||||||
|
await message.channel.send(`User ${user.toString()} was not found in the channel.`);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}
|
Loading…
Reference in a new issue