mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-29 05:35:38 -05:00
Revamp guild registration and add other stuff.
This commit is contained in:
parent
cdc9ecd1da
commit
cbe2c02b74
@ -88,6 +88,36 @@ export default {
|
|||||||
client.statsGraph = -(interaction.options.getInteger('number', true))
|
client.statsGraph = -(interaction.options.getInteger('number', true))
|
||||||
interaction.reply(`Successfully set to \`${client.statsGraph}\`\n*Total data points: **${JSON.parse(readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).length.toLocaleString()}***`);
|
interaction.reply(`Successfully set to \`${client.statsGraph}\`\n*Total data points: **${JSON.parse(readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).length.toLocaleString()}***`);
|
||||||
break
|
break
|
||||||
|
case 'presence':
|
||||||
|
function convertType(Type?: number){
|
||||||
|
switch (Type) {
|
||||||
|
case 0: return 'Playing';
|
||||||
|
case 1: return 'Streaming';
|
||||||
|
case 2: return 'Listening to';
|
||||||
|
case 3: return 'Watching';
|
||||||
|
case 5: return 'Competing in';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const status = interaction.options.getString('status') as Discord.PresenceStatusData | null;
|
||||||
|
const type = interaction.options.getInteger('type');
|
||||||
|
const name = interaction.options.getString('name');
|
||||||
|
const url = interaction.options.getString('url');
|
||||||
|
const currentActivities = client.config.botPresence.activities as Discord.ActivitiesOptions[];
|
||||||
|
|
||||||
|
if (status) client.config.botPresence.status = status;
|
||||||
|
if (type) currentActivities[0].type = type;
|
||||||
|
if (name) currentActivities[0].name = name;
|
||||||
|
if (url) currentActivities[0].url = url;
|
||||||
|
|
||||||
|
client.user.setPresence(client.config.botPresence);
|
||||||
|
interaction.reply([
|
||||||
|
'Presence updated:',
|
||||||
|
`Status: **${client.config.botPresence.status}**`,
|
||||||
|
`Type: **${convertType(currentActivities[0].type)}**`,
|
||||||
|
`Name: **${currentActivities[0].name}**`,
|
||||||
|
`URL: \`${currentActivities[0].url}\``
|
||||||
|
].join('\n'))
|
||||||
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
@ -116,4 +146,32 @@ export default {
|
|||||||
.setName('number')
|
.setName('number')
|
||||||
.setDescription('Number of data points to pull')
|
.setDescription('Number of data points to pull')
|
||||||
.setRequired(true)))
|
.setRequired(true)))
|
||||||
|
.addSubcommand((optt)=>optt
|
||||||
|
.setName('presence')
|
||||||
|
.setDescription('Update the bot\'s presence')
|
||||||
|
.addIntegerOption((hiTae)=>hiTae
|
||||||
|
.setName('type')
|
||||||
|
.setDescription('Set an activity type')
|
||||||
|
.addChoices(
|
||||||
|
{name: 'Playing', value: Discord.ActivityType.Playing},
|
||||||
|
{name: 'Streaming', value: Discord.ActivityType.Streaming},
|
||||||
|
{name: 'Listening to', value: Discord.ActivityType.Listening},
|
||||||
|
{name: 'Watching', value: Discord.ActivityType.Watching},
|
||||||
|
{name: 'Competing in', value: Discord.ActivityType.Competing}
|
||||||
|
))
|
||||||
|
.addStringOption((hiAgain)=>hiAgain
|
||||||
|
.setName('name')
|
||||||
|
.setDescription('Set a message for the activity status'))
|
||||||
|
.addStringOption((hiAgainx2)=>hiAgainx2
|
||||||
|
.setName('url')
|
||||||
|
.setDescription('Set an url for streaming status'))
|
||||||
|
.addStringOption((hiAgainx3)=>hiAgainx3
|
||||||
|
.setName('status')
|
||||||
|
.setDescription('Set a status indicator for the bot')
|
||||||
|
.setChoices(
|
||||||
|
{name: 'Online', value: Discord.PresenceUpdateStatus.Online},
|
||||||
|
{name: 'Idle', value: Discord.PresenceUpdateStatus.Idle},
|
||||||
|
{name: 'Do Not Distrub', value: Discord.PresenceUpdateStatus.DoNotDisturb},
|
||||||
|
{name: 'Invisible', value: Discord.PresenceUpdateStatus.Offline}
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
"embedColorBCA": "#ff69b4",
|
"embedColorBCA": "#ff69b4",
|
||||||
"embedColorXmas": "#FFFFFF",
|
"embedColorXmas": "#FFFFFF",
|
||||||
"LRSstart": 1661236321433,
|
"LRSstart": 1661236321433,
|
||||||
|
"whitelistedServers": [
|
||||||
|
"929807948748832798", "468835415093411861", "1058183358267543552"
|
||||||
|
],
|
||||||
"botSwitches": {
|
"botSwitches": {
|
||||||
"registerCommands": true,
|
"registerCommands": true,
|
||||||
"commands": true,
|
"commands": true,
|
||||||
@ -15,6 +18,12 @@
|
|||||||
"mpstats": true,
|
"mpstats": true,
|
||||||
"autores": true
|
"autores": true
|
||||||
},
|
},
|
||||||
|
"botPresence": {
|
||||||
|
"activities": [
|
||||||
|
{"name": "the days go by", "url": "https://www.youtube.com/watch?v=8UVNT4wvIGY", "type": 1}
|
||||||
|
],
|
||||||
|
"status": "online"
|
||||||
|
},
|
||||||
"eval": {
|
"eval": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"whitelist": [
|
"whitelist": [
|
||||||
|
@ -9,12 +9,10 @@ import {Punishment, UserLevels, FSData, FSCareerSavegame} from './typings/interf
|
|||||||
client.on('ready', async()=>{
|
client.on('ready', async()=>{
|
||||||
client.guilds.cache.forEach(async(e)=>{await e.members.fetch()});
|
client.guilds.cache.forEach(async(e)=>{await e.members.fetch()});
|
||||||
setInterval(async()=>{
|
setInterval(async()=>{
|
||||||
client.user.setPresence({activities: [{ name: 'the days go by', type: 3, url: 'https://www.youtube.com/watch?v=D-UmfqFjpl0' }], status: 'online'});
|
client.user.setPresence(client.config.botPresence);
|
||||||
// Playing: 0, Streaming (Requires YT/Twitch URL to work): 1, Listening to: 2, Watching: 3, Competing in: 5
|
}, 300000);
|
||||||
}, 60000);
|
|
||||||
// ['929807948748832798', '468835415093411861', '1058183358267543552', '549114074273677314'] - 0=Dev Server, 1=Main Server, 2=Throne, 3=Toast's test server
|
|
||||||
if (client.config.botSwitches.registerCommands){
|
if (client.config.botSwitches.registerCommands){
|
||||||
['929807948748832798', '468835415093411861', '1058183358267543552'].forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
|
client.config.whitelistedServers.forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
|
||||||
console.log(`Couldn't register slash commands for ${guildId} because`, e.stack);
|
console.log(`Couldn't register slash commands for ${guildId} because`, e.stack);
|
||||||
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
|
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
|
||||||
}));
|
}));
|
||||||
@ -30,6 +28,7 @@ client.on('ready', async()=>{
|
|||||||
}, 500000);
|
}, 500000);
|
||||||
console.log(`${client.user.tag} has logged into Discord API and now ready for operation`);
|
console.log(`${client.user.tag} has logged into Discord API and now ready for operation`);
|
||||||
console.log(client.config.botSwitches);
|
console.log(client.config.botSwitches);
|
||||||
|
console.log(client.config.whitelistedServers);
|
||||||
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
|
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
|
||||||
|
|
||||||
// Event handler
|
// Event handler
|
||||||
|
2
src/typings/interfaces.d.ts
vendored
2
src/typings/interfaces.d.ts
vendored
@ -132,7 +132,9 @@ export interface Config {
|
|||||||
embedColorBCA: ColorResolvable,
|
embedColorBCA: ColorResolvable,
|
||||||
embedColorXmas: ColorResolvable,
|
embedColorXmas: ColorResolvable,
|
||||||
LRSstart: number,
|
LRSstart: number,
|
||||||
|
whitelistedServers: Array<string>,
|
||||||
botSwitches: botSwitches,
|
botSwitches: botSwitches,
|
||||||
|
botPresence: Discord.PresenceData,
|
||||||
eval: Eval,
|
eval: Eval,
|
||||||
mainServer: mainServer
|
mainServer: mainServer
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user