mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
Stupid GitHub formatting...
This commit is contained in:
parent
f0045d5980
commit
1fae7257b6
@ -1,2 +1,3 @@
|
|||||||
# Daggerbot-TS
|
![https://discord.gg/4SnUAFu](https://cdn.discordapp.com/attachments/1015195575693627442/1081877631068295178/DaggerwinServerBanner2023.gif)
|
||||||
TypeScript-based Daggerbot converted from JavaScript at [SpaceManBuzz/DaggerBot-](https://github.com/SpaceManBuzz/DaggerBot-)
|
# Daggerbot-TS Description
|
||||||
|
This is 1st generation bot that is a TypeScript-based Daggerbot converted from JavaScript at (now archived and privated) ~~[SpaceManBuzz/DaggerBot-](https://github.com/SpaceManBuzz/DaggerBot-)~~
|
@ -53,7 +53,7 @@ export default class TClient extends Client {
|
|||||||
super({
|
super({
|
||||||
intents: [
|
intents: [
|
||||||
GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers,
|
GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers,
|
||||||
GatewayIntentBits.GuildBans, GatewayIntentBits.GuildInvites,
|
GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildInvites,
|
||||||
GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages
|
GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages
|
||||||
],
|
],
|
||||||
partials: [
|
partials: [
|
||||||
@ -61,7 +61,7 @@ export default class TClient extends Client {
|
|||||||
Partials.Reaction,
|
Partials.Reaction,
|
||||||
Partials.Message
|
Partials.Message
|
||||||
],
|
],
|
||||||
allowedMentions: { users: [], roles: [] }
|
allowedMentions: {users:[],roles:[]}
|
||||||
})
|
})
|
||||||
this.invites = new Map();
|
this.invites = new Map();
|
||||||
this.commands = new Discord.Collection();
|
this.commands = new Discord.Collection();
|
||||||
@ -91,6 +91,7 @@ export default class TClient extends Client {
|
|||||||
this.statsGraph = -60;
|
this.statsGraph = -60;
|
||||||
}
|
}
|
||||||
async init(){
|
async init(){
|
||||||
|
console.time('Startup');
|
||||||
mongoose.set('strictQuery', true);
|
mongoose.set('strictQuery', true);
|
||||||
await mongoose.connect(this.tokens.mongodb_uri, {
|
await mongoose.connect(this.tokens.mongodb_uri, {
|
||||||
replicaSet: 'toastyy',
|
replicaSet: 'toastyy',
|
||||||
@ -123,9 +124,7 @@ export default class TClient extends Client {
|
|||||||
achievedAccuracy++;
|
achievedAccuracy++;
|
||||||
text += fullTimelengths + (options?.longNames ? (' '+timeName.name+(fullTimelengths === 1 ? '' : 's')) : timeName.name.slice(0, timeName.name === 'month' ? 2 : 1)) + (options?.commas ? ', ' : ' ');
|
text += fullTimelengths + (options?.longNames ? (' '+timeName.name+(fullTimelengths === 1 ? '' : 's')) : timeName.name.slice(0, timeName.name === 'month' ? 2 : 1)) + (options?.commas ? ', ' : ' ');
|
||||||
integer -= fullTimelengths*timeName.length;
|
integer -= fullTimelengths*timeName.length;
|
||||||
} else {
|
} else break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (text.length == 0) text = integer + (options?.longNames ? ' milliseconds' : 'ms') + (options?.commas ? ', ' : '');
|
if (text.length == 0) text = integer + (options?.longNames ? ' milliseconds' : 'ms') + (options?.commas ? ', ' : '');
|
||||||
if (options?.commas){
|
if (options?.commas){
|
||||||
@ -137,24 +136,19 @@ export default class TClient extends Client {
|
|||||||
}
|
}
|
||||||
} return text.trim();
|
} return text.trim();
|
||||||
}
|
}
|
||||||
isStaff(guildMember: Discord.GuildMember){
|
isStaff = (guildMember:Discord.GuildMember)=>this.config.mainServer.staffRoles.map((x: string)=>this.config.mainServer.roles[x]).some((x: string)=>guildMember.roles.cache.has(x));
|
||||||
return this.config.mainServer.staffRoles.map((x: string)=>this.config.mainServer.roles[x]).some((x: string)=>guildMember.roles.cache.has(x))
|
|
||||||
}
|
youNeedRole = (interaction:Discord.CommandInteraction, role:string)=>interaction.reply(`This command is restricted to <@&${this.config.mainServer.roles[role]}>`);
|
||||||
youNeedRole(interaction: Discord.CommandInteraction, role:string){
|
|
||||||
return interaction.reply(`This command is restricted to <@&${this.config.mainServer.roles[role]}>`)
|
logTime = ()=>`[${this.moment().format('DD/MM/YY HH:mm:ss')}]`;
|
||||||
}
|
|
||||||
logTime(){
|
|
||||||
return `[${this.moment().format('DD/MM/YY HH:mm:ss')}]`
|
|
||||||
}
|
|
||||||
alignText(text: string, length: number, alignment: string, emptyChar = ' '){
|
alignText(text: string, length: number, alignment: string, emptyChar = ' '){
|
||||||
if (alignment == 'right'){
|
if (alignment == 'right') text = emptyChar.repeat(length - text.length)+text;
|
||||||
text = emptyChar.repeat(length - text.length)+text;
|
else if (alignment == 'middle'){
|
||||||
} else if (alignment == 'middle'){
|
|
||||||
const emptyCharsPerSide = (length - text.length)/2;
|
const emptyCharsPerSide = (length - text.length)/2;
|
||||||
text = emptyChar.repeat(Math.floor(emptyCharsPerSide))+text+emptyChar.repeat(Math.floor(emptyCharsPerSide));
|
text = emptyChar.repeat(Math.floor(emptyCharsPerSide))+text+emptyChar.repeat(Math.floor(emptyCharsPerSide));
|
||||||
} else {
|
} else text = text + emptyChar.repeat(length - text.length);
|
||||||
text = text + emptyChar.repeat(length - text.length);
|
return text;
|
||||||
} return text;
|
|
||||||
}
|
}
|
||||||
async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){
|
async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){
|
||||||
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod");
|
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod");
|
||||||
@ -176,9 +170,7 @@ export default class TClient extends Client {
|
|||||||
let error;
|
let error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.axios.get(`https://www.youtube.com/feeds/videos.xml?channel_id=${YTChannelID}`, {timeout: 5000}).then((xml:any)=>{
|
await this.axios.get(`https://www.youtube.com/feeds/videos.xml?channel_id=${YTChannelID}`, {timeout: 5000}).then((xml:any)=>Data = this.xjs.xml2js(xml.data, {compact: true, spaces: 2}))
|
||||||
Data = this.xjs.xml2js(xml.data, {compact: true, spaces: 2});
|
|
||||||
})
|
|
||||||
} catch(err){
|
} catch(err){
|
||||||
error = true;
|
error = true;
|
||||||
console.log(this.logTime(), `${YTChannelName} YT fail`)
|
console.log(this.logTime(), `${YTChannelName} YT fail`)
|
||||||
@ -196,5 +188,12 @@ export default class TClient extends Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WClient extends WebhookClient {tokens: Tokens; constructor(){super({url: tokens.webhook_url})}}
|
export class WClient extends WebhookClient {
|
||||||
|
tokens: Tokens;
|
||||||
|
constructor(){
|
||||||
|
super({
|
||||||
|
url: tokens.webhook_url
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
// hi tae, ik you went to look for secret hello msgs in here too.
|
// hi tae, ik you went to look for secret hello msgs in here too.
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
client.punish(client, interaction, 'ban');
|
client.punish(client, interaction, 'ban');
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -21,11 +21,11 @@ export default {
|
|||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('bannedwords')
|
.setName('bannedwords')
|
||||||
.setDescription('description placeholder')
|
.setDescription('description placeholder')/*
|
||||||
/*.addSubcommand((opt)=>opt
|
.addSubcommand((opt)=>opt
|
||||||
.setName('view')
|
.setName('view')
|
||||||
.setDescription('View the list of currently banned words.'))
|
.setDescription('View the list of currently banned words.'))*/
|
||||||
*/.addSubcommand((opt)=>opt
|
.addSubcommand((opt)=>opt
|
||||||
.setName('add')
|
.setName('add')
|
||||||
.setDescription('What word do you want to add?')
|
.setDescription('What word do you want to add?')
|
||||||
.addStringOption((optt)=>optt
|
.addStringOption((optt)=>optt
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from "discord.js";
|
import Discord,{SlashCommandBuilder} from "discord.js";
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
if (!client.isStaff(interaction.member)) return client.youNeedRole(interaction, 'dcmod');
|
if (!client.isStaff(interaction.member)) return client.youNeedRole(interaction, 'dcmod');
|
||||||
const caseId = interaction.options.getInteger('id');
|
const caseId = interaction.options.getInteger('id');
|
||||||
({
|
({
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).setTitle('Daggerbot contributors').setDescription([
|
interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).setTitle('Daggerbot contributors').setDescription([
|
||||||
'**Thanks to those below that contributed to the bot!**',
|
'**Thanks to those below that contributed to the bot!**',
|
||||||
'Toast <@190407856527376384>',
|
'Toast <@190407856527376384>',
|
||||||
|
@ -20,7 +20,7 @@ const removeUsername = (text: string)=>{
|
|||||||
} return array.join('\\');
|
} return array.join('\\');
|
||||||
};
|
};
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
|
||||||
if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech');
|
if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech');
|
||||||
({
|
({
|
||||||
eval: async()=>{
|
eval: async()=>{
|
||||||
@ -45,11 +45,9 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (error) return;
|
if (error) return;
|
||||||
if (typeof output == 'object') {
|
if (typeof output == 'object') output = 'js\n'+util.formatWithOptions({depth: 1}, '%O', output)
|
||||||
output = 'js\n'+util.formatWithOptions({depth: 1}, '%O', output)
|
else output = '\n' + String(output);
|
||||||
} else {
|
|
||||||
output = '\n' + String(output);
|
|
||||||
}
|
|
||||||
[client.tokens.main,client.tokens.beta,client.tokens.toast,client.tokens.tae,client.tokens.webhook_url,client.tokens.webhook_url_test,client.tokens.mongodb_uri,client.tokens.mongodb_uri_dev].forEach((x)=>{
|
[client.tokens.main,client.tokens.beta,client.tokens.toast,client.tokens.tae,client.tokens.webhook_url,client.tokens.webhook_url_test,client.tokens.mongodb_uri,client.tokens.mongodb_uri_dev].forEach((x)=>{
|
||||||
const regexp = new RegExp(x as string,'g');
|
const regexp = new RegExp(x as string,'g');
|
||||||
output = output.replace(regexp, ':noblank: No token?');
|
output = output.replace(regexp, ':noblank: No token?');
|
||||||
@ -67,13 +65,9 @@ export default {
|
|||||||
const fetchCommitAuthor = await octokit.repos.getCommit(githubRepo).then(x=>x.data.commit.author.name).catch(err=>{console.log(err); interaction.reply({content: 'Placeholder error for `fetchCommitAuthor`', ephemeral: true})});
|
const fetchCommitAuthor = await octokit.repos.getCommit(githubRepo).then(x=>x.data.commit.author.name).catch(err=>{console.log(err); interaction.reply({content: 'Placeholder error for `fetchCommitAuthor`', ephemeral: true})});
|
||||||
const clarkson = await interaction.reply({content: 'Pulling from repository...', fetchReply: true});
|
const clarkson = await interaction.reply({content: 'Pulling from repository...', fetchReply: true});
|
||||||
exec('git pull',(err:Error,stdout)=>{
|
exec('git pull',(err:Error,stdout)=>{
|
||||||
if (err){
|
if (err) clarkson.edit(`\`\`\`${removeUsername(err.message)}\`\`\``)
|
||||||
clarkson.edit(`\`\`\`${removeUsername(err.message)}\`\`\``)
|
else if (stdout.includes('Already up to date')) clarkson.edit('Bot is already up to date with the repository, did you forgor to push the changes? :skull:')
|
||||||
} else if (stdout.includes('Already up to date')){
|
else setTimeout(()=>clarkson.edit(`Commit: **${fetchCommitMsg}**\nCommit author: **${fetchCommitAuthor}**\n\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot')),650)
|
||||||
clarkson.edit('Bot is already up to date with the repository, did you forgor to push the changes? :skull:')
|
|
||||||
} else {
|
|
||||||
setTimeout(()=>{clarkson.edit(`Commit: **${fetchCommitMsg}**\nCommit author: **${fetchCommitAuthor}**\n\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))},650)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
presence: ()=>{
|
presence: ()=>{
|
||||||
@ -112,9 +106,7 @@ export default {
|
|||||||
interaction.deferReply();
|
interaction.deferReply();
|
||||||
(client.channels.resolve(client.config.mainServer.channels.console) as Discord.TextChannel).send({content: `Uploaded the current console dump as of <t:${Math.round(Date.now()/1000)}:R>`, files: [`${process.env.pm2_home}/logs/Daggerbot-out-0.log`, `${process.env.pm2_home}/logs/Daggerbot-error-0.log`]}).then(()=>interaction.editReply('It has been uploaded to dev server.')).catch((e:Error)=>interaction.editReply(`\`${e.message}\``))
|
(client.channels.resolve(client.config.mainServer.channels.console) as Discord.TextChannel).send({content: `Uploaded the current console dump as of <t:${Math.round(Date.now()/1000)}:R>`, files: [`${process.env.pm2_home}/logs/Daggerbot-out-0.log`, `${process.env.pm2_home}/logs/Daggerbot-error-0.log`]}).then(()=>interaction.editReply('It has been uploaded to dev server.')).catch((e:Error)=>interaction.editReply(`\`${e.message}\``))
|
||||||
},
|
},
|
||||||
restart: ()=>{
|
restart: ()=>interaction.reply(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))
|
||||||
interaction.reply(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))
|
|
||||||
}
|
|
||||||
} as any)[interaction.options.getSubcommand()]();
|
} as any)[interaction.options.getSubcommand()]();
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
({
|
({
|
||||||
srp: ()=>interaction.reply('Ballyspring is the map that is used in Survival Roleplay S4.'),
|
srp: ()=>interaction.reply('Ballyspring is the map that is used in Survival Roleplay S4.'),
|
||||||
dlskin: ()=>interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).setTitle('Daggerwin Logistics hex code').setDescription('The main color will be Onyx (`#353839`) with red bumpers.').setImage('https://cdn.discordapp.com/attachments/801965516947324969/806871878736019456/image0.png')]}),
|
dlskin: ()=>interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).setTitle('Daggerwin Logistics hex code').setDescription('The main color will be Onyx (`#353839`) with red bumpers.').setImage('https://cdn.discordapp.com/attachments/801965516947324969/806871878736019456/image0.png')]}),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
client.punish(client, interaction, 'kick');
|
client.punish(client, interaction, 'kick');
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -24,12 +24,11 @@ async function MPdata(client:TClient, interaction:Discord.ChatInputCommandIntera
|
|||||||
embed.setColor(client.config.embedColorRed);
|
embed.setColor(client.config.embedColorRed);
|
||||||
console.log(client.logTime(), 'DagMP failed to fetch, host didn\'t respond in time.');
|
console.log(client.logTime(), 'DagMP failed to fetch, host didn\'t respond in time.');
|
||||||
return interaction.reply('Server didn\'t respond in time.');
|
return interaction.reply('Server didn\'t respond in time.');
|
||||||
}
|
} return FSserver
|
||||||
return FSserver
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
if (interaction.channelId == '468835769092669461' && !client.isStaff(interaction.member) && ['status', 'players'].includes(interaction.options.getSubcommand())) {
|
if (interaction.channelId == '468835769092669461' && !client.isStaff(interaction.member) && ['status', 'players'].includes(interaction.options.getSubcommand())) {
|
||||||
interaction.reply(`Please use <#739084625862852715> for \`/mp status/players\` commands to prevent clutter in this channel.`).then((msg)=>{setTimeout(()=>{interaction.deleteReply()}, 6000)});
|
interaction.reply(`Please use <#739084625862852715> for \`/mp status/players\` commands to prevent clutter in this channel.`).then((msg)=>{setTimeout(()=>{interaction.deleteReply()}, 6000)});
|
||||||
return;
|
return;
|
||||||
@ -41,14 +40,13 @@ export default {
|
|||||||
if (!FSserver0?.data) return console.log('FSserver0 failed - status');
|
if (!FSserver0?.data) return console.log('FSserver0 failed - status');
|
||||||
try {
|
try {
|
||||||
if (FSserver0.data.server.name.length > 1){
|
if (FSserver0.data.server.name.length > 1){
|
||||||
embed0.setTitle('Status/Details').setColor(client.config.embedColor).addFields(
|
interaction.reply({embeds: [embed0.setTitle('Status/Details').setColor(client.config.embedColor).addFields(
|
||||||
{name: 'Server name', value: `${FSserver0?.data.server.name.length == 0 ? '\u200b' : `\`${FSserver0?.data.server.name}\``}`, inline: true},
|
{name: 'Server name', value: `${FSserver0?.data.server.name.length == 0 ? '\u200b' : `\`${FSserver0?.data.server.name}\``}`, inline: true},
|
||||||
{name: 'Players', value: `${FSserver0.data.slots.used} out of ${FSserver0.data.slots.capacity}`, inline: true},
|
{name: 'Players', value: `${FSserver0.data.slots.used} out of ${FSserver0.data.slots.capacity}`, inline: true},
|
||||||
{name: 'Current map', value: `${FSserver0?.data.server.mapName.length == 0 ? '\u200b' : FSserver0.data.server.mapName}`, inline: true},
|
{name: 'Current map', value: `${FSserver0?.data.server.mapName.length == 0 ? '\u200b' : FSserver0.data.server.mapName}`, inline: true},
|
||||||
{name: 'Version', value: `${FSserver0?.data.server.version.length == 0 ? '\u200b' : FSserver0.data.server.version}`, inline: true},
|
{name: 'Version', value: `${FSserver0?.data.server.version.length == 0 ? '\u200b' : FSserver0.data.server.version}`, inline: true},
|
||||||
{name: 'In-game Time', value: `${('0' + Math.floor((FSserver0.data.server.dayTime/3600/1000))).slice(-2)}:${('0' + Math.floor((FSserver0.data.server.dayTime/60/1000)%60)).slice(-2)}`, inline: true}
|
{name: 'In-game Time', value: `${('0' + Math.floor((FSserver0.data.server.dayTime/3600/1000))).slice(-2)}:${('0' + Math.floor((FSserver0.data.server.dayTime/60/1000)%60)).slice(-2)}`, inline: true}
|
||||||
)
|
)]})
|
||||||
interaction.reply({embeds: [embed0]})
|
|
||||||
} else if (FSserver0.data.server.name.length == 0) interaction.reply('Server is currently offline.')
|
} else if (FSserver0.data.server.name.length == 0) interaction.reply('Server is currently offline.')
|
||||||
} catch (err){
|
} catch (err){
|
||||||
console.log(err)
|
console.log(err)
|
||||||
@ -60,7 +58,7 @@ export default {
|
|||||||
const FSserver2 = await MPdata(client, interaction, embed2)
|
const FSserver2 = await MPdata(client, interaction, embed2)
|
||||||
if (!FSserver2?.data) return console.log('FSserver2 failed - info')
|
if (!FSserver2?.data) return console.log('FSserver2 failed - info')
|
||||||
const MPURL = await client.MPServer._content.findById(interaction.guildId);
|
const MPURL = await client.MPServer._content.findById(interaction.guildId);
|
||||||
embed2.setDescription([
|
interaction.reply({embeds: [embed2.setDescription([
|
||||||
`**Server name**: \`${FSserver2?.data.server.name.length == 0 ? '\u200b' : FSserver2?.data.server.name}\``,
|
`**Server name**: \`${FSserver2?.data.server.name.length == 0 ? '\u200b' : FSserver2?.data.server.name}\``,
|
||||||
'**Password:** `mf4700`',
|
'**Password:** `mf4700`',
|
||||||
'**Crossplay server**',
|
'**Crossplay server**',
|
||||||
@ -68,9 +66,8 @@ export default {
|
|||||||
`**Mods:** [Click here](${MPURL.ip}/mods.html) **|** [Direct Download](${MPURL.ip}/all_mods_download?onlyActive=true)`,
|
`**Mods:** [Click here](${MPURL.ip}/mods.html) **|** [Direct Download](${MPURL.ip}/all_mods_download?onlyActive=true)`,
|
||||||
'**Filters:** [Click here](https://discord.com/channels/468835415093411861/468835769092669461/926581585938120724)',
|
'**Filters:** [Click here](https://discord.com/channels/468835415093411861/468835769092669461/926581585938120724)',
|
||||||
'Please see <#543494084363288637> for additional information.'
|
'Please see <#543494084363288637> for additional information.'
|
||||||
].join('\n'));
|
].join('\n'))]});
|
||||||
if (FSserver2?.data.server.name.length == 0) embed2.setFooter({text: 'Server is currently offline.'})
|
if (FSserver2?.data.server.name.length == 0) embed2.setFooter({text: 'Server is currently offline.'})
|
||||||
interaction.reply({embeds: [embed2]})
|
|
||||||
},
|
},
|
||||||
url: async()=>{
|
url: async()=>{
|
||||||
if (client.config.mainServer.id == interaction.guildId) {
|
if (client.config.mainServer.id == interaction.guildId) {
|
||||||
@ -170,11 +167,9 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function colorAtPlayercount(playercount: number) {
|
function colorAtPlayercount(playercount: number) {
|
||||||
if (playercount === first_graph_top) {
|
if (playercount === first_graph_top) return client.config.embedColorRed as string;
|
||||||
return client.config.embedColorRed as string;
|
else if (playercount > 9) return client.config.embedColorYellow as string;
|
||||||
} else if (playercount > 9) {
|
else return client.config.embedColorGreen as string
|
||||||
return client.config.embedColorYellow as string;
|
|
||||||
} else {return client.config.embedColorGreen as string}
|
|
||||||
}
|
}
|
||||||
let lastCoords: Array<number> = [];
|
let lastCoords: Array<number> = [];
|
||||||
data.forEach((curPC: number /* current player count */, i: number) => {
|
data.forEach((curPC: number /* current player count */, i: number) => {
|
||||||
@ -197,9 +192,7 @@ export default {
|
|||||||
grd.addColorStop(stop, client.config.embedColorYellow as string); // add a yellow stop to the gradient
|
grd.addColorStop(stop, client.config.embedColorYellow as string); // add a yellow stop to the gradient
|
||||||
}
|
}
|
||||||
ctx.strokeStyle = grd;
|
ctx.strokeStyle = grd;
|
||||||
} else {
|
} else ctx.strokeStyle = colorAtPlayercount(curPC);
|
||||||
ctx.strokeStyle = colorAtPlayercount(curPC);
|
|
||||||
}
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
if (lastCoords.length > 0) ctx.moveTo(lastCoords[0], lastCoords[1]);
|
if (lastCoords.length > 0) ctx.moveTo(lastCoords[0], lastCoords[1]);
|
||||||
// if the line being drawn is horizontal, make it go until it has to go down
|
// if the line being drawn is horizontal, make it go until it has to go down
|
||||||
@ -209,16 +202,13 @@ export default {
|
|||||||
if (data[j] === curPC) newX += nodeWidth; else break;
|
if (data[j] === curPC) newX += nodeWidth; else break;
|
||||||
}
|
}
|
||||||
ctx.lineTo(newX, y);
|
ctx.lineTo(newX, y);
|
||||||
} else {
|
} else ctx.lineTo(x, y);
|
||||||
ctx.lineTo(x, y);
|
|
||||||
}
|
|
||||||
lastCoords = [x, y];
|
lastCoords = [x, y];
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
|
|
||||||
if (curPC === prvPC && curPC === nexPC) {
|
if (curPC === prvPC && curPC === nexPC) return; // no ball because no vertical difference to next or prev point
|
||||||
return; // no ball because no vertical difference to next or prev point
|
else {
|
||||||
} else {
|
|
||||||
// ball
|
// ball
|
||||||
ctx.fillStyle = colorAtPlayercount(curPC);
|
ctx.fillStyle = colorAtPlayercount(curPC);
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
@ -257,9 +247,7 @@ export default {
|
|||||||
embed1.setTitle(FSserver1?.data.server.name.length == 0 ? 'Offline' : FSserver1?.data.server.name)
|
embed1.setTitle(FSserver1?.data.server.name.length == 0 ? 'Offline' : FSserver1?.data.server.name)
|
||||||
.setDescription(`${FSserver1?.data.slots.used}/${FSserver1?.data.slots.capacity}`)
|
.setDescription(`${FSserver1?.data.slots.used}/${FSserver1?.data.slots.capacity}`)
|
||||||
.setColor(FSserver1?.data.server.name.length == 0 ? client.config.embedColorRed : client.config.embedColor);
|
.setColor(FSserver1?.data.server.name.length == 0 ? client.config.embedColorRed : client.config.embedColor);
|
||||||
FSserver1?.data.slots.players.filter(x=>x.isUsed).forEach(player=>{
|
FSserver1?.data.slots.players.filter(x=>x.isUsed).forEach(player=>embed1.addFields({name: `${player.name} ${player.isAdmin ? '| admin' : ''}`, value: `Farming for ${(Math.floor(player.uptime/60))} hr, ${('0' + (player.uptime % 60)).slice(-2)} min`}))
|
||||||
embed1.addFields({name: `${player.name} ${player.isAdmin ? '| admin' : ''}`, value: `Farming for ${(Math.floor(player.uptime/60))} hr, ${('0' + (player.uptime % 60)).slice(-2)} min`})
|
|
||||||
})
|
|
||||||
interaction.reply({embeds: [embed1], files: [Image]})
|
interaction.reply({embeds: [embed1], files: [Image]})
|
||||||
}/*,
|
}/*,
|
||||||
series: ()=>{
|
series: ()=>{
|
||||||
@ -293,8 +281,8 @@ export default {
|
|||||||
.setDescription('View the URL for this server\'s FSMP server or update the URL')
|
.setDescription('View the URL for this server\'s FSMP server or update the URL')
|
||||||
.addStringOption((opt)=>opt
|
.addStringOption((opt)=>opt
|
||||||
.setName('address')
|
.setName('address')
|
||||||
.setDescription('Insert a \'dedicated-server-stats\' URL')))
|
.setDescription('Insert a \'dedicated-server-stats\' URL')))/*
|
||||||
/* .addSubcommand((opt)=>opt
|
.addSubcommand((opt)=>opt
|
||||||
.setName('series')
|
.setName('series')
|
||||||
.setDescription('Step-by-step on joining Daggerwin\'s MP series')) */
|
.setDescription('Step-by-step on joining Daggerwin\'s MP series'))*/
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
client.punish(client, interaction, 'mute');
|
client.punish(client, interaction, 'mute');
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -10,15 +10,13 @@ export default {
|
|||||||
let messagesArray: Array<string> = [];
|
let messagesArray: Array<string> = [];
|
||||||
|
|
||||||
if (user){
|
if (user){
|
||||||
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then((msgs)=>{
|
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then(msgs=>{
|
||||||
const msgList = msgs.filter(x=>x.author.id == user.id);
|
const msgList = msgs.filter(x=>x.author.id == user.id);
|
||||||
(interaction.channel as Discord.TextChannel).bulkDelete(msgList);
|
(interaction.channel as Discord.TextChannel).bulkDelete(msgList);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then(async messages=>{
|
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then(async messages=>{
|
||||||
messages.forEach(message=>{
|
messages.forEach(message=>messagesArray.push(message.id));
|
||||||
messagesArray.push(message.id);
|
|
||||||
});
|
|
||||||
await (interaction.channel as Discord.TextChannel).bulkDelete(messagesArray);
|
await (interaction.channel as Discord.TextChannel).bulkDelete(messagesArray);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
const embed = new client.embed().setColor(Math.floor(Math.random()*16777215));
|
const embed = new client.embed().setColor(Math.floor(Math.random()*16777215));
|
||||||
embed.addFields({name: 'Hex code', value: `#${embed.data.color.toString(16).toUpperCase()}`});
|
embed.addFields({name: 'Hex code', value: `#${embed.data.color.toString(16).toUpperCase()}`});
|
||||||
interaction.reply({embeds: [embed]});
|
interaction.reply({embeds: [embed]});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
const role = interaction.options.getRole('role') as Discord.Role;
|
const role = interaction.options.getRole('role') as Discord.Role;
|
||||||
const permissions = role.permissions.toArray();
|
const permissions = role.permissions.toArray();
|
||||||
const Role = role.members.map((e:Discord.GuildMember)=>`**${e.user.tag}**`).join('\n') || '';
|
const Role = role.members.map((e:Discord.GuildMember)=>`**${e.user.tag}**`).join('\n') || '';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
client.punish(client, interaction, 'softban');
|
client.punish(client, interaction, 'softban');
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -5,7 +5,7 @@ import TClient from 'src/client';
|
|||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
// Host specification (L9-L22, L55-L70)
|
// Host specification (L9-L22, L51-L66)
|
||||||
// Bytes conversion
|
// Bytes conversion
|
||||||
function formatBytes(bytes:number, decimals:number = 2) {
|
function formatBytes(bytes:number, decimals:number = 2) {
|
||||||
if (bytes === 0) return '0 Bytes';
|
if (bytes === 0) return '0 Bytes';
|
||||||
@ -21,7 +21,7 @@ export default {
|
|||||||
const osInfo = await si.osInfo();
|
const osInfo = await si.osInfo();
|
||||||
const currentLoad = await si.currentLoad();
|
const currentLoad = await si.currentLoad();
|
||||||
|
|
||||||
// Command usage (L25-L54)
|
// Command usage (L25-L50)
|
||||||
const columns = ['Command name', 'Count'];
|
const columns = ['Command name', 'Count'];
|
||||||
const includedCommands = client.commands.filter(x=>x.uses).sort((a,b)=>b.uses - a.uses);
|
const includedCommands = client.commands.filter(x=>x.uses).sort((a,b)=>b.uses - a.uses);
|
||||||
if (includedCommands.size == 0) return interaction.reply(`No commands have been used yet.\nUptime: **${client.formatTime(client.uptime as number, 3, {longNames: true, commas: true})}**`);
|
if (includedCommands.size == 0) return interaction.reply(`No commands have been used yet.\nUptime: **${client.formatTime(client.uptime as number, 3, {longNames: true, commas: true})}**`);
|
||||||
@ -44,14 +44,10 @@ export default {
|
|||||||
if (fieldValue.length + row.length > 1024){
|
if (fieldValue.length + row.length > 1024){
|
||||||
embed.addFields({name: '\u200b', value: `\`\`\`\n${fieldValue}\`\`\``});
|
embed.addFields({name: '\u200b', value: `\`\`\`\n${fieldValue}\`\`\``});
|
||||||
fieldValue = row;
|
fieldValue = row;
|
||||||
} else {
|
} else fieldValue += row
|
||||||
fieldValue += row;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
embed.addFields({name: '\u200b', value: `\`\`\`\n${fieldValue}\`\`\``});
|
embed.addFields({name: '\u200b', value: `\`\`\`\n${fieldValue}\`\`\``});
|
||||||
} else {
|
} else embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``});
|
||||||
embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``})
|
|
||||||
};
|
|
||||||
embed.addFields(
|
embed.addFields(
|
||||||
{name: '> __Dependencies__', value: [
|
{name: '> __Dependencies__', value: [
|
||||||
`**TypeScript:** ${version}`,
|
`**TypeScript:** ${version}`,
|
||||||
@ -66,11 +62,11 @@ export default {
|
|||||||
`**NodeJS:** ${formatBytes(process.memoryUsage().heapUsed)}/${formatBytes(process.memoryUsage().heapTotal)}`,
|
`**NodeJS:** ${formatBytes(process.memoryUsage().heapUsed)}/${formatBytes(process.memoryUsage().heapTotal)}`,
|
||||||
`**Load Usage:**\nUser: ${currentLoad.currentLoadUser.toFixed(1)}%\nSystem: ${currentLoad.currentLoadSystem.toFixed(1)}%`,
|
`**Load Usage:**\nUser: ${currentLoad.currentLoadUser.toFixed(1)}%\nSystem: ${currentLoad.currentLoadSystem.toFixed(1)}%`,
|
||||||
`**Uptime:**\nHost: ${client.formatTime((os.uptime()*1000), 2, {longNames: true, commas: true})}\nBot: ${client.formatTime(client.uptime as number, 2, {commas: true, longNames: true})}`
|
`**Uptime:**\nHost: ${client.formatTime((os.uptime()*1000), 2, {longNames: true, commas: true})}\nBot: ${client.formatTime(client.uptime as number, 2, {commas: true, longNames: true})}`
|
||||||
].join('\n')} // Nice
|
].join('\n')}
|
||||||
);
|
);
|
||||||
interaction.reply({embeds: [embed], fetchReply: true}).then((x)=>x.edit({embeds: [new client.embed(x.embeds[0].data).setFooter({text: `Load time: ${client.formatTime(x.createdTimestamp - interaction.createdTimestamp, 2, {longNames: true, commas: true})}`})]}))
|
interaction.reply({embeds: [embed], fetchReply: true}).then((x)=>x.edit({embeds: [new client.embed(x.embeds[0].data).setFooter({text: `Load time: ${client.formatTime(x.createdTimestamp - interaction.createdTimestamp, 2, {longNames: true, commas: true})}`})]}))
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()// Nice
|
||||||
.setName('statistics')
|
.setName('statistics')
|
||||||
.setDescription('See a list of commands ordered by their usage or host stats')
|
.setDescription('See a list of commands ordered by their usage or host stats')
|
||||||
}
|
}
|
@ -56,7 +56,7 @@ export default {
|
|||||||
]});
|
]});
|
||||||
await client.suggestion._content.findByIdAndUpdate(suggestionIDReply, {state: 'Rejected'});
|
await client.suggestion._content.findByIdAndUpdate(suggestionIDReply, {state: 'Rejected'});
|
||||||
return interaction.reply({embeds:[new client.embed().setColor(client.config.embedColorRed).setTitle(`Suggestion rejected | ${suggestionIDReply}`).setDescription(stateChanged)]});
|
return interaction.reply({embeds:[new client.embed().setColor(client.config.embedColorRed).setTitle(`Suggestion rejected | ${suggestionIDReply}`).setDescription(stateChanged)]});
|
||||||
},
|
}
|
||||||
} as any)[interaction.options.getSubcommand()]();
|
} as any)[interaction.options.getSubcommand()]();
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
export default {
|
export default {
|
||||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
client.punish(client, interaction, 'warn');
|
client.punish(client, interaction, 'warn');
|
||||||
},
|
},
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -2,15 +2,12 @@ import Discord,{GuildMember, SlashCommandBuilder} from 'discord.js';
|
|||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
|
|
||||||
function convert(status?:Discord.ClientPresenceStatus){
|
function convert(status?:Discord.ClientPresenceStatus){
|
||||||
if (status){
|
if (status) return {
|
||||||
return {
|
|
||||||
idle: '🟡',
|
idle: '🟡',
|
||||||
dnd: '🔴',
|
dnd: '🔴',
|
||||||
online: '🟢'
|
online: '🟢'
|
||||||
}[status];
|
}[status];
|
||||||
} else {
|
else return '⚫'
|
||||||
return '⚫'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -31,11 +28,9 @@ export default {
|
|||||||
const presence = member.presence?.clientStatus as Discord.ClientPresenceStatusData;
|
const presence = member.presence?.clientStatus as Discord.ClientPresenceStatusData;
|
||||||
const embedArray = [];
|
const embedArray = [];
|
||||||
let title = 'Member';
|
let title = 'Member';
|
||||||
if (member.user.bot) {
|
if (member.user.bot) title = 'Bot';
|
||||||
title = 'Bot'
|
else if (member.user.id == interaction.guild.ownerId) title = ':crown: Server Owner';
|
||||||
} else if (member.user.id == interaction.guild.ownerId) {
|
|
||||||
title = ':crown: Server Owner'
|
|
||||||
};
|
|
||||||
const embed = new client.embed()
|
const embed = new client.embed()
|
||||||
.setColor(member.displayColor || client.config.embedColor)
|
.setColor(member.displayColor || client.config.embedColor)
|
||||||
.setURL(`https://discord.com/users/${member.user.id}`)
|
.setURL(`https://discord.com/users/${member.user.id}`)
|
||||||
|
@ -15,26 +15,17 @@ export class Database {
|
|||||||
this._content = dataType === 'array' ? [] : {};
|
this._content = dataType === 'array' ? [] : {};
|
||||||
}
|
}
|
||||||
addData(data: any, data1?: any){
|
addData(data: any, data1?: any){
|
||||||
if (Array.isArray(this._content)){
|
if (Array.isArray(this._content)) this._content.push(data);
|
||||||
this._content.push(data);
|
else if (typeof this._content === 'object') this._content[data] = data1;
|
||||||
} else if (typeof this._content === 'object'){
|
|
||||||
this._content[data] = data1;
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
removeData(key: any, type: number, element: any){
|
removeData(key: any, type: number, element: any){
|
||||||
if (this._dataType === 'array'){
|
if (this._dataType === 'array'){
|
||||||
switch (type){
|
({
|
||||||
case 0:
|
0: ()=>this._content = this._content.filter((x:any)=>x!=key),
|
||||||
this._content = this._content.filter((x:any)=>x != key);
|
1: ()=>this._content = this._content.filter((x:any)=>x[element]!=key)
|
||||||
break;
|
})[type]()
|
||||||
case 1:
|
} else if (this._dataType === 'object') delete this._content[key];
|
||||||
this._content = this._content.filter((x:any)=>x[element] != key);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (this._dataType === 'object'){
|
|
||||||
delete this._content[key];
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
initLoad(){
|
initLoad(){
|
||||||
@ -64,6 +55,4 @@ export class Database {
|
|||||||
console.log(this._path + ' "DB saved" Notifications disabled');
|
console.log(this._path + ' "DB saved" Notifications disabled');
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // Nice.
|
|
||||||
|
@ -7,14 +7,11 @@ export default {
|
|||||||
const banLog = fetchBanlog.entries.first();
|
const banLog = fetchBanlog.entries.first();
|
||||||
if (!banLog) return console.log(`${member.user.tag} was banned from ${member.guild.name} but no audit log for this user.`)
|
if (!banLog) return console.log(`${member.user.tag} was banned from ${member.guild.name} but no audit log for this user.`)
|
||||||
const {executor, target, reason } = banLog;
|
const {executor, target, reason } = banLog;
|
||||||
if (target.id == member.user.id) {
|
if (target.id == member.user.id) (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
||||||
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
|
||||||
new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
||||||
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
||||||
{name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified': reason}`}
|
{name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified': reason}`}
|
||||||
)]})
|
)]});
|
||||||
} else {
|
else console.log(`${target.tag} was banned from ${member.guild.name} but no audit log could be fetched.`)
|
||||||
console.log(`${target.tag} was banned from ${member.guild.name} but no audit log could be fetched.`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,11 @@ export default {
|
|||||||
const unbanLog = fetchUnbanlog.entries.first();
|
const unbanLog = fetchUnbanlog.entries.first();
|
||||||
if (!unbanLog) return console.log(`${member.user.tag} was unbanned from ${member.guild.name} but no audit log for this user.`)
|
if (!unbanLog) return console.log(`${member.user.tag} was unbanned from ${member.guild.name} but no audit log for this user.`)
|
||||||
const { executor, target, reason } = unbanLog;
|
const { executor, target, reason } = unbanLog;
|
||||||
if (target.id == member.user.id) {
|
if (target.id == member.user.id) (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
||||||
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
|
||||||
new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Unbanned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Unbanned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
||||||
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
||||||
{name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified.': reason}`}
|
{name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified.': reason}`}
|
||||||
)]})
|
)]});
|
||||||
} else {
|
else console.log(`${target.tag} was unbanned from ${member.guild.name} but no audit log could be fetched.`)
|
||||||
console.log(`${target.tag} was unbanned from ${member.guild.name} but no audit log could be fetched.`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,14 @@ export default {
|
|||||||
const index = member.guild.memberCount;
|
const index = member.guild.memberCount;
|
||||||
const suffix = ((index)=>{
|
const suffix = ((index)=>{
|
||||||
const numbers = index.toString().split('').reverse(); // eg 1850 --> [0,5,8,1]
|
const numbers = index.toString().split('').reverse(); // eg 1850 --> [0,5,8,1]
|
||||||
if (numbers[1] === '1'){// this is some -teen
|
if (numbers[1] === '1') return 'th'; // this is some -teen
|
||||||
return 'th';
|
else {
|
||||||
} else {
|
|
||||||
if (numbers[0] === '1') return 'st';
|
if (numbers[0] === '1') return 'st';
|
||||||
else if (numbers[0] === '2') return 'nd';
|
else if (numbers[0] === '2') return 'nd';
|
||||||
else if (numbers[0] === '3') return 'rd';
|
else if (numbers[0] === '3') return 'rd';
|
||||||
else return 'th';
|
else return 'th';
|
||||||
}
|
}
|
||||||
})(index);
|
})(index);
|
||||||
|
|
||||||
(client.channels.resolve(client.config.mainServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to Daggerwin, ${member.user.tag}!`).setFooter({text: `${index}${suffix} member`})]})
|
(client.channels.resolve(client.config.mainServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to Daggerwin, ${member.user.tag}!`).setFooter({text: `${index}${suffix} member`})]})
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
const newInvites = await member.guild.invites.fetch();
|
const newInvites = await member.guild.invites.fetch();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import TClient from '../client';
|
import TClient from '../client';
|
||||||
export default {
|
export default {
|
||||||
async run(client:TClient, oldMember:Discord.GuildMember, newMember:Discord.GuildMember){
|
run(client:TClient, oldMember:Discord.GuildMember, newMember:Discord.GuildMember){
|
||||||
if (oldMember.guild.id != client.config.mainServer.id) return;
|
if (oldMember.guild.id != client.config.mainServer.id) return;
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
const channel = (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel)
|
const channel = (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import TClient from '../client';
|
import TClient from '../client';
|
||||||
export default {
|
export default {
|
||||||
async run(client:TClient, interaction:Discord.BaseInteraction){
|
run(client:TClient, interaction:Discord.BaseInteraction){
|
||||||
if (!interaction.inGuild() || !interaction.inCachedGuild()) return;
|
if (!interaction.inGuild() || !interaction.inCachedGuild()) return;
|
||||||
if (interaction.isChatInputCommand()){
|
if (interaction.isChatInputCommand()){
|
||||||
const commandFile = client.commands.get(interaction.commandName);
|
const commandFile = client.commands.get(interaction.commandName);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import TClient from '../client';
|
import TClient from '../client';
|
||||||
export default {
|
export default {
|
||||||
async run(client:TClient, invite: Discord.Invite){
|
run(client:TClient, invite: Discord.Invite){
|
||||||
client.invites.delete(invite.code)
|
client.invites.delete(invite.code)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,9 +10,7 @@ export default {
|
|||||||
delete client.repeatedMessages[message.author.id]
|
delete client.repeatedMessages[message.author.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Whitelist = [
|
const Whitelist = [] // Array of channel ids for automod to be disabled in (Disables bannedWords and advertisement, mind you.)
|
||||||
// Arrary of channel ids for automod to be disabled in
|
|
||||||
]
|
|
||||||
|
|
||||||
if (await client.bannedWords._content.findOne({_id:msgarr}) && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId) && client.config.botSwitches.automod){
|
if (await client.bannedWords._content.findOne({_id:msgarr}) && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId) && client.config.botSwitches.automod){
|
||||||
automodded = true;
|
automodded = true;
|
||||||
@ -45,6 +43,7 @@ export default {
|
|||||||
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {cont: 0, ch: message.channelId});
|
client.repeatedMessages[message.author.id].data.set(message.createdTimestamp, {cont: 0, ch: message.channelId});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.content.toLowerCase().includes('discord.gg/') && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId)) {
|
if (message.content.toLowerCase().includes('discord.gg/') && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId)) {
|
||||||
automodded = true;
|
automodded = true;
|
||||||
const threshold = 60000;
|
const threshold = 60000;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import TClient from '../client';
|
import TClient from '../client';
|
||||||
export default {
|
export default {
|
||||||
async run(client:TClient, msg:Discord.Message){
|
run(client:TClient, msg:Discord.Message){
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
||||||
const disabledChannels = ['548032776830582794', '541677709487505408']
|
const disabledChannels = [ '548032776830582794', '541677709487505408']
|
||||||
if (msg.guild?.id != client.config.mainServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return;
|
if (msg.guild?.id != client.config.mainServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return;
|
||||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.tag} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``);
|
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.tag} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``);
|
||||||
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${msg.content.slice(0,1000)}\n\`\`\``});
|
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${msg.content.slice(0,1000)}\n\`\`\``});
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import TClient from '../client';
|
import TClient from '../client';
|
||||||
export default {
|
export default {
|
||||||
async run(client:TClient, messages:Discord.Collection<string, Discord.Message<boolean>>){
|
run(client:TClient, messages:Discord.Collection<string, Discord.Message<boolean>>){
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
if (client.config.mainServer.id != '468835415093411861') return;
|
if (client.config.mainServer.id != '468835415093411861') return;
|
||||||
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
||||||
channel.send({embeds: [new client.embed().setColor(client.config.embedColorRed).setTimestamp().setTitle(`${messages.size} messages were purged`).setDescription(`\`\`\`${messages.map((msgs)=>`${msgs.member?.displayName}: ${msgs.content}`).reverse().join('\n').slice(0,3900)}\`\`\``).addFields({name: 'Channel', value: `<#${messages.first().channel.id}>`})]})
|
channel.send({embeds: [new client.embed().setColor(client.config.embedColorRed).setTimestamp().setTitle(`${messages.size} messages were purged`)
|
||||||
|
.setDescription(`\`\`\`${messages.map((msgs)=>`${msgs.member?.displayName}: ${msgs.content}`).reverse().join('\n').slice(0,3900)}\`\`\``).addFields(
|
||||||
|
{name: 'Channel', value: `<#${messages.first().channel.id}>`}
|
||||||
|
)]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,6 @@ export default {
|
|||||||
const msgarr = newMsg.content.toLowerCase().split(' ');
|
const msgarr = newMsg.content.toLowerCase().split(' ');
|
||||||
if (await client.bannedWords._content.findOne({_id:msgarr}) && (!client.isStaff(newMsg.member))) newMsg.delete();
|
if (await client.bannedWords._content.findOne({_id:msgarr}) && (!client.isStaff(newMsg.member))) newMsg.delete();
|
||||||
if (newMsg.content === oldMsg.content) return;
|
if (newMsg.content === oldMsg.content) return;
|
||||||
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.tag} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content}\n\`\`\`\nNew content:\n\`\`\`\n${newMsg.content}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]});
|
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.tag} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : oldMsg.content}\n\`\`\`\nNew content:\n\`\`\`\n${newMsg.content}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ client.on('ready', async()=>{
|
|||||||
console.log(`${client.user.tag} has logged into Discord API`);
|
console.log(`${client.user.tag} has logged into Discord API`);
|
||||||
console.log(client.config.botSwitches, client.config.whitelistedServers);
|
console.log(client.config.botSwitches, 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')}\`\`\``);
|
||||||
|
console.timeEnd('Startup')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
@ -116,9 +117,7 @@ setInterval(async()=>{
|
|||||||
{name: 'Slot Usage', value: `${slotSystem}`, inline: true},
|
{name: 'Slot Usage', value: `${slotSystem}`, inline: true},
|
||||||
{name: 'Timescale', value: `${timeScale}`, inline: true}
|
{name: 'Timescale', value: `${timeScale}`, inline: true}
|
||||||
);
|
);
|
||||||
FSdss.data.slots.players.filter((x)=>x.isUsed !== false).forEach(player=>{
|
FSdss.data.slots.players.filter((x)=>x.isUsed !== false).forEach(player=>Players.push(`**${player.name} ${player.isAdmin ? '| admin' : ''}**\nFarming for ${(Math.floor(player.uptime/60))} hr & ${('' + (player.uptime % 60)).slice(-2)} min`))
|
||||||
Players.push(`**${player.name} ${player.isAdmin ? '| admin' : ''}**\nFarming for ${(Math.floor(player.uptime/60))} hr & ${('' + (player.uptime % 60)).slice(-2)} min`)
|
|
||||||
})
|
|
||||||
embed.setDescription(`${FSdss.data.slots.used == 0 ? '*No players online*' : Players.join('\n\n')}`).setTitle(FSdss.data.server.name).setColor(client.config.embedColor)
|
embed.setDescription(`${FSdss.data.slots.used == 0 ? '*No players online*' : Players.join('\n\n')}`).setTitle(FSdss.data.server.name).setColor(client.config.embedColor)
|
||||||
embed.setAuthor({name: `${FSdss.data.slots.used}/${FSdss.data.slots.capacity}`});
|
embed.setAuthor({name: `${FSdss.data.slots.used}/${FSdss.data.slots.capacity}`});
|
||||||
msg.edit({content: 'This embed updates every minute.', embeds: [embed1, embed]})
|
msg.edit({content: 'This embed updates every minute.', embeds: [embed1, embed]})
|
||||||
@ -148,9 +147,7 @@ setInterval(async()=>{
|
|||||||
if (!dailyMsgs.some((x:Array<number>)=>x[0] === formattedDate)){
|
if (!dailyMsgs.some((x:Array<number>)=>x[0] === formattedDate)){
|
||||||
let total = (await client.userLevels._content.find({})).reduce((a,b)=>a + b.messages, 0); // sum of all users
|
let total = (await client.userLevels._content.find({})).reduce((a,b)=>a + b.messages, 0); // sum of all users
|
||||||
const yesterday = dailyMsgs.find((x:Array<number>)=>x[0] === formattedDate - 1);
|
const yesterday = dailyMsgs.find((x:Array<number>)=>x[0] === formattedDate - 1);
|
||||||
if (total < yesterday){ // messages went down.
|
if (total < yesterday) total = yesterday // messages went down.
|
||||||
total = yesterday
|
|
||||||
}
|
|
||||||
dailyMsgs.push([formattedDate, total]);
|
dailyMsgs.push([formattedDate, total]);
|
||||||
fs.writeFileSync(__dirname + '/database/dailyMsgs.json', JSON.stringify(dailyMsgs))
|
fs.writeFileSync(__dirname + '/database/dailyMsgs.json', JSON.stringify(dailyMsgs))
|
||||||
console.log(client.logTime(), `Pushed [${formattedDate}, ${total}] to dailyMsgs`);
|
console.log(client.logTime(), `Pushed [${formattedDate}, ${total}] to dailyMsgs`);
|
||||||
|
Loading…
Reference in New Issue
Block a user