Skip to content

Commit

Permalink
Discord.js v14 and added some commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
CSP02 committed Sep 8, 2022
1 parent ada2398 commit fd6e37a
Show file tree
Hide file tree
Showing 93 changed files with 7,744 additions and 2,526 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
.vs
.vscode

node_modules/
Binary file added Images/infr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


> The default prefix is "!".
(Prefix is same for every Guild/Server will release an update to make it able to change for different guilds.)

* It is a discord bot for moderation.
Expand Down Expand Up @@ -40,7 +39,6 @@ warn | - | warns the mentioned member | @staff
infraction | infr, wi | replies with the warning of the given infraction ID | @staff

> Inorder to know more about the commands join my discord server.
### Version Info:
* Added Slash Commands (a few but will release a minor release after adding more slash commands),
* Added error handling which sends a embed message to the channel describing the error,
Expand All @@ -59,7 +57,6 @@ infraction | infr, wi | replies with the warning of the given infraction ID | @
### Command usage:
```
Example:
You:
!ping
The bot:
Expand Down
23 changes: 23 additions & 0 deletions SlashCommands/slashKill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
name: 'kill',
data: new SlashCommandBuilder()
.setName('kill')
.setDescription('kills the mentioned member')
.addUserOption(option =>
option.setName('target')
.setDescription('mention a user to kill.')
.setRequired(true)
),

async execute(client, interaction, Discord) {
const weapons = ['AK47', 'M24', 'Chopper', 'knife', 'sword', 'hammer', 'crusher', 'ball', 'punch', 'joke', 'cringe face']
const randomIndex = Math.floor(Math.random() * weapons.length);
const user = interaction.options.getUser('target');
const embedmsg = new Discord.MessageEmbed()
.setTitle("**Killed**")
.setDescription(`You killed ${user} with a ${weapons[randomIndex]}.`)
.setColor('#fc03fc')
interaction.reply({ embeds: [embedmsg] });
}
}
106 changes: 106 additions & 0 deletions SlashCommands/specialGift.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
const { SlashCommandBuilder } = require('discord.js');
const mongo = require('../schemas/mongo')
const giftSchema = require('../schemas/giftSchema')
module.exports = {
name: 'gift',
data: new SlashCommandBuilder()
.setName('gift')
.setDescription('Sends a gift to a user!')
.addUserOption(option =>
option.setName('target')
.setDescription('The user to send the gift')
.setRequired(true)
)
.addStringOption(option =>
option.setName('gifts')
.setDescription('The gift you want to send')
.setRequired(true)
.addChoices(
{ name: 'Cake', value: 'cake' },
{ name: 'ToyCar', value: 'toyCar' },
{ name: 'ChessBoard', value: 'chessBoard' },
{ name: 'ToyTrain', value: 'toyTrain' },
{ name: 'Vibe check', value: 'vibeCheck' },
{ name: 'PS-4', value: 'PS4' }
)
),

async execute(client, interaction, Discord) {
await interaction.deferReply();
const rateMap = new Map()
rateMap.set('cake', 23)
rateMap.set('toyCar', 50)
rateMap.set('toyTrain', 84)
rateMap.set('chessBoard', 56)
rateMap.set('vibeCheck', 86)
rateMap.set('PS4', 97)
const target = interaction.options.getUser('target')
const gift = interaction.options.getString('gifts')
const userID = interaction.user.id
const colors = ['#ff9645', '#ffeb6b', '#e6ff6b', '#baff6b', '#6bff95', '#6bffc4', '#6bfffd', '#6bd0ff', '#6b9cff', '#726bff', '#936bff', '#ae6bff', '#ce6bff', '#e96bff', '#ff6bee', '#ff3bc4', '#ff2495', '#ff2469']
const randomIndex = Math.floor(Math.random() * colors.length);

const giftRate = rateMap.get(gift)
let totalPoints = {
total: parseInt('0', 10),
totalGifts: parseInt('0', 10)
}
await mongo().then(async mongoose => {

try {
const giftsPoints = await giftSchema.findOne({ userID })
if (giftsPoints !== null) {


const { total, totalGifts } = giftsPoints.gifts[0]
if (total <= giftRate) {
return interaction.editReply('You didnt have enough coins to buy and send this item.')
}
const tot = total - giftRate
let totalGiftsSent = totalGifts + 1
await mongo().then(async mongoose => {
try {
await giftSchema.findOneAndUpdate({
userID
}, {
userID,
$pull: {
gifts: giftsPoints.gifts[0]
}
})
} finally {
mongoose.connection.close()
}
})

totalPoints = { total: tot, totalGifts: totalGiftsSent }
} else {
return interaction.editReply('You didn\'t have enough coins use ``!collect`` (yes its not a slash command) command to collect some coins.')
}
await mongo().then(async mongoose => {
try {
await giftSchema.findOneAndUpdate({
userID
}, {
userID,
$push: {
gifts: totalPoints
}
}, {
upsert: true
})
} finally {
mongoose.connection.close()
}
})
} finally {
mongoose.connection.close()
}
})
const embed = new Discord.MessageEmbed()
.setTitle('Gift received')
.setColor(`${colors[randomIndex]}`)
.setDescription(`<@${userID}> has send you a ${gift} which is ${giftRate}CCs(chistmas coins).`)
await interaction.editReply({ content: `<@${target.id}>`, embeds: [embed] });
}
}
12 changes: 12 additions & 0 deletions commands/EasterEggs/crypace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
name: 'crypace',
aliases: ['crypace', 'game'],

execute (client, message, args, Discord){
const embedMsg = new Discord.EmbedBuilder()
.setTitle('Found an easter egg 😁:')
.setDescription('Crypace is a sci-fi game being developed by some people in Atelier server.\nAnd those people has created dreamspace games.\n')
.setColor('#3d86fc')
message.channel.send({embeds: [embedMsg]})
}
}
Loading

0 comments on commit fd6e37a

Please sign in to comment.