mirror of
https://github.com/System-End/Discord-Bot.git
synced 2026-04-19 19:45:16 +00:00
Fixed another bugs
This commit is contained in:
parent
75b47ca7d9
commit
e6c9badf90
12 changed files with 108 additions and 64 deletions
13
.env.example
13
.env.example
|
|
@ -1,10 +1,15 @@
|
|||
DISCORD_TOKEN=
|
||||
MONGO_TOKEN=
|
||||
GIPHY_TOKEN=
|
||||
TOPGG_TOKEN=
|
||||
WEBHOOK_ID=
|
||||
WEBHOOK_TOKEN=
|
||||
|
||||
# Not neccessary variables
|
||||
DISCORD_STATUS="Listening to meself, I'm a stupid bot, https://github.com/corwindev/discord-bot"
|
||||
RADIO=
|
||||
TOPGG_TOKEN=
|
||||
SPOTIFY_CLIENT_ID=
|
||||
SPOTIFY_CLIENT_SECRET=
|
||||
LAVALINK_HOST=
|
||||
LAVALINK_PASSWORD=
|
||||
LAVALINK_PORT=
|
||||
LAVALINK_HOST=lava.link
|
||||
LAVALINK_PASSWORD=I'm a secret
|
||||
LAVALINK_PORT=80
|
||||
9
.replit
Normal file
9
.replit
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
language = "nodejs"
|
||||
run = "npm start"
|
||||
|
||||
[env]
|
||||
DISCORD_TOKEN = "fillin"
|
||||
MONGO_TOKEN = "fillin"
|
||||
GIPHY_TOKEN = "fillin"
|
||||
WEBHOOK_ID = "fillin"
|
||||
WEBHOOK_TOKEN = "fillin"
|
||||
75
src/bot.js
75
src/bot.js
|
|
@ -52,33 +52,54 @@ const client = new Discord.Client({
|
|||
|
||||
const clientID = process.env.SPOTIFY_CLIENT_ID;
|
||||
const clientSecret = process.env.SPOTIFY_CLIENT_SECRET;
|
||||
|
||||
// Lavalink client
|
||||
client.player = new Manager({
|
||||
plugins: [
|
||||
new AppleMusic(),
|
||||
new Deezer(),
|
||||
new Facebook(),
|
||||
new Spotify({
|
||||
clientID,
|
||||
clientSecret,
|
||||
playlistLimit: 100,
|
||||
albumLimit: 100
|
||||
})
|
||||
],
|
||||
nodes: [
|
||||
{
|
||||
host: process.env.LAVALINK_HOST,
|
||||
port: parseInt(process.env.LAVALINK_PORT),
|
||||
password: process.env.LAVALINK_PASSWORD,
|
||||
if (clientID && clientSecret) {
|
||||
// Lavalink client
|
||||
client.player = new Manager({
|
||||
plugins: [
|
||||
new AppleMusic(),
|
||||
new Deezer(),
|
||||
new Facebook(),
|
||||
new Spotify({
|
||||
clientID,
|
||||
clientSecret,
|
||||
playlistLimit: 100,
|
||||
albumLimit: 100
|
||||
})
|
||||
],
|
||||
nodes: [
|
||||
{
|
||||
host: process.env.LAVALINK_HOST || "lava.link",
|
||||
port: parseInt(process.env.LAVALINK_PORT) || 80,
|
||||
password: process.env.LAVALINK_PASSWORD || "CorwinDev"
|
||||
},
|
||||
],
|
||||
send(id, payload) {
|
||||
const guild = client.guilds.cache.get(id);
|
||||
if (guild) guild.shard.send(payload);
|
||||
},
|
||||
],
|
||||
send(id, payload) {
|
||||
const guild = client.guilds.cache.get(id);
|
||||
if (guild) guild.shard.send(payload);
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
} else {
|
||||
// Lavalink client
|
||||
client.player = new Manager({
|
||||
plugins: [
|
||||
new AppleMusic(),
|
||||
new Deezer(),
|
||||
new Facebook(),
|
||||
],
|
||||
nodes: [
|
||||
{
|
||||
host: process.env.LAVALINK_HOST || "lava.link",
|
||||
port: parseInt(process.env.LAVALINK_PORT) || 80,
|
||||
password: process.env.LAVALINK_PASSWORD || "CorwinDev"
|
||||
},
|
||||
],
|
||||
send(id, payload) {
|
||||
const guild = client.guilds.cache.get(id);
|
||||
if (guild) guild.shard.send(payload);
|
||||
}
|
||||
})
|
||||
}
|
||||
const events = fs.readdirSync(`./src/events/music`).filter(files => files.endsWith('.js'));
|
||||
|
||||
for (const file of events) {
|
||||
|
|
@ -164,8 +185,8 @@ client.login(process.env.DISCORD_TOKEN);
|
|||
|
||||
process.on('unhandledRejection', error => {
|
||||
console.error('Unhandled promise rejection:', error);
|
||||
if(error) if (error.length > 950) error = error.slice(0, 950) + '... view console for details';
|
||||
if(error.stack) if (error.stack.length > 950) error.stack = error.stack.slice(0, 950) + '... view console for details';
|
||||
if (error) if (error.length > 950) error = error.slice(0, 950) + '... view console for details';
|
||||
if (error.stack) if (error.stack.length > 950) error.stack = error.stack.slice(0, 950) + '... view console for details';
|
||||
const embed = new Discord.EmbedBuilder()
|
||||
.setTitle(`🚨・Unhandled promise rejection`)
|
||||
.addFields([
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ module.exports = async (client, interaction, args) => {
|
|||
|
||||
interaction.channel.awaitMessageComponent({ filter, max: 1 }).then(async i => {
|
||||
if (i.customId == 'customSelect') {
|
||||
await i.deferUpdate();
|
||||
if (i.values[0] === "command-embed") {
|
||||
new Schema({
|
||||
Guild: interaction.guild.id,
|
||||
|
|
@ -57,6 +58,7 @@ module.exports = async (client, interaction, args) => {
|
|||
value: `\`\`\`${cmdname.toLowerCase()}\`\`\``,
|
||||
inline: true,
|
||||
}],
|
||||
components: [],
|
||||
type: 'editreply'
|
||||
}, i);
|
||||
}
|
||||
|
|
@ -76,6 +78,7 @@ module.exports = async (client, interaction, args) => {
|
|||
value: `\`\`\`${cmdname.toLowerCase()}\`\`\``,
|
||||
inline: true,
|
||||
}],
|
||||
components: [],
|
||||
type: 'editreply'
|
||||
}, i);
|
||||
}
|
||||
|
|
@ -95,6 +98,7 @@ module.exports = async (client, interaction, args) => {
|
|||
value: `\`\`\`${cmdname.toLowerCase()}\`\`\``,
|
||||
inline: true,
|
||||
}],
|
||||
components: [],
|
||||
type: 'editreply'
|
||||
}, i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ const Schema = require("../../database/models/customCommandAdvanced");
|
|||
|
||||
module.exports = async (client, interaction, args) => {
|
||||
const cmdname = interaction.options.getString('command');
|
||||
|
||||
Schema.findOne({ Guild: interaction.guild.id, Name: cmdname.toLowerCase() }, async (err, data) => {
|
||||
console.log(data)
|
||||
if (data) {
|
||||
Schema.findOneAndDelete({ Guild: interaction.guild.id, Name: cmdname }).then(async () => {
|
||||
const command = await interaction.guild.commands.cache.find((cmd => cmd.name == cmdname));
|
||||
Schema.findOneAndDelete({ Guild: interaction.guild.id, Name: cmdname.toLowerCase() }).then(async () => {
|
||||
var commands = await interaction.guild.commands.fetch()
|
||||
var command = await commands.find((cmd => cmd.name == cmdname.toLowerCase()))
|
||||
if(!command) return client.errNormal({ error: "Unable to find this command!", type: 'editreply' }, interaction );
|
||||
await interaction.guild.commands.delete(command.id);
|
||||
|
||||
client.succNormal({
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ module.exports = async (client, interaction, args) => {
|
|||
const role = interaction.options.getRole('role');
|
||||
const emoji = interaction.options.getString('emoji');
|
||||
|
||||
const parsedEmoji = Discord.Util.parseEmoji(emoji);
|
||||
const parsedEmoji = Discord.parseEmoji(emoji);
|
||||
if (!parsedEmoji) return client.errNormal({
|
||||
error: `Emoji not found in this server!`,
|
||||
type: 'editreply'
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
|||
module.exports = async (client, interaction, args) => {
|
||||
|
||||
const emoji = interaction.options.getString('emoji');
|
||||
const parsedEmoji = Discord.Util.parseEmoji(emoji)
|
||||
const parsedEmoji = Discord.parseEmoji(emoji)
|
||||
|
||||
if (parsedEmoji) {
|
||||
const ex = parsedEmoji.animated ? ".gif" : ".png";
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
discord: {
|
||||
id: "840212110817755157",
|
||||
id: process.env.DISCORD_ID,
|
||||
prefix: '!',
|
||||
footer: `© Corwin 2021 - ${new Date().getFullYear()}`,
|
||||
botInvite: `https://discord.com/oauth2/authorize?&client_id=840212110817755157&scope=applications.commands+bot&permissions=8`,
|
||||
|
|
|
|||
|
|
@ -34,23 +34,25 @@ module.exports = async (client, interaction) => {
|
|||
Name: interaction.commandName,
|
||||
});
|
||||
if (cmdx) {
|
||||
// Remove interaction
|
||||
if (cmdx.Action == "Normal") {
|
||||
return interaction.channel.send({ content: cmdx.Responce });
|
||||
return interaction.reply({ content: cmdx.Responce });
|
||||
} else if (cmdx.Action == "Embed") {
|
||||
return client.simpleEmbed(
|
||||
{
|
||||
desc: `${cmdx.Responce}`,
|
||||
type: 'editreply'
|
||||
},
|
||||
interaction.channel,
|
||||
interaction,
|
||||
);
|
||||
} else if (cmdx.Action == "DM") {
|
||||
return interaction.author.send({ content: cmdx.Responce }).catch((e) => {
|
||||
interaction.deleteReply();
|
||||
return interaction.user.send({ content: cmdx.Responce }).catch((e) => {
|
||||
client.errNormal(
|
||||
{
|
||||
error: "I can't DM you, maybe you have DM turned off!",
|
||||
},
|
||||
interaction.channel
|
||||
interaction
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const Discord = require('discord.js');
|
||||
const chalk = require('chalk');
|
||||
const { random } = require('mathjs');
|
||||
|
||||
module.exports = async (client) => {
|
||||
const startLogs = new Discord.WebhookClient({
|
||||
|
|
@ -31,29 +32,24 @@ module.exports = async (client) => {
|
|||
return Promise.all(promises)
|
||||
.then(results => {
|
||||
const totalGuilds = results[0].reduce((acc, guildCount) => acc + guildCount, 0);
|
||||
|
||||
let statuttext = [
|
||||
`・❓┆/help`,
|
||||
`・💻┆${totalGuilds} servers`,
|
||||
`・📨┆discord.me/Bot`,
|
||||
`・🎉┆400+ commands`,
|
||||
`・🏷️┆Version ${require(`${process.cwd()}/package.json`).version}`
|
||||
];
|
||||
let statuttext;
|
||||
if (process.env.DISCORD_STATUS) {
|
||||
statuttext = process.env.DISCORD_STATUS.split(', ');
|
||||
} else {
|
||||
statuttext = [
|
||||
`・❓┆/help`,
|
||||
`・💻┆${totalGuilds} servers`,
|
||||
`・📨┆discord.me/corwindev`,
|
||||
`・🎉┆400+ commands`,
|
||||
`・🏷️┆Version ${require(`${process.cwd()}/package.json`).version}`
|
||||
];
|
||||
}
|
||||
const randomText = statuttext[Math.floor(Math.random() * statuttext.length)];
|
||||
|
||||
client.user.setPresence({
|
||||
activities: [
|
||||
{
|
||||
name: randomText,
|
||||
type: "STREAMING",
|
||||
url: "https://www.twitch.tv/discord"
|
||||
}
|
||||
]
|
||||
});
|
||||
client.user.setActivity('activity', { type: Discord.ActivityType.Streaming });
|
||||
client.user.setPresence({ activities: [{ name: randomText }], status: 'online' });
|
||||
})
|
||||
}, 50000)
|
||||
|
||||
client.player.init(client.user.id);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -64,17 +64,17 @@ module.exports = (client) => {
|
|||
|
||||
player.on('stateChange', (oldState, newState) => {
|
||||
if (newState.status === Voice.AudioPlayerStatus.Idle) {
|
||||
client.startStream(process.env.RADIO)
|
||||
client.startStream(process.env.RADIO || "https://playerservices.streamtheworld.com/api/livestream-redirect/RADIO538")
|
||||
}
|
||||
});
|
||||
|
||||
player.on('error', error => {
|
||||
client.emit("voiceError", error);
|
||||
client.startStream(process.env.RADIO);
|
||||
client.startStream(process.env.RADIO || "https://playerservices.streamtheworld.com/api/livestream-redirect/RADIO538");
|
||||
});
|
||||
|
||||
client.on('ready', async () => {
|
||||
client.startStream(process.env.RADIO);
|
||||
client.startStream(process.env.RADIO || "https://playerservices.streamtheworld.com/api/livestream-redirect/RADIO538");
|
||||
|
||||
Schema.find(async (err, data) => {
|
||||
if (data) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,13 @@ module.exports = {
|
|||
.setName('soundboard')
|
||||
.setDescription('Play all the sounds in Bot')
|
||||
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName('help')
|
||||
.setDescription('Get information about the soundboard category commands')
|
||||
)
|
||||
|
||||
// Windows Sounds
|
||||
|
||||
.addSubcommandGroup((group) =>
|
||||
group
|
||||
.setName('windows')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue