Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env-example

This file was deleted.

16 changes: 0 additions & 16 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.14.0
88 changes: 44 additions & 44 deletions commands/giveaways/start-giveaway.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
const { MessageEmbed } = require('discord.js');
const Commando = require('discord.js-commando');
const addMilliseconds = require('date-fns/addMilliseconds')
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { addMilliseconds } = require('date-fns');

module.exports = {
data: new SlashCommandBuilder()
.setName('giveaway')
.setDescription('Fa partire l\'estrazione di un premio')
.addIntegerOption(option =>
option.setName('minuti')
.setDescription('Durata del giveaway in minuti')
.setRequired(true)
.setMinValue(1))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),

async execute(interaction) {
const minutes = interaction.options.getInteger('minuti');
const time = minutes * 60000;

module.exports = class StartGiveawayCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'giveaway',
group: 'giveaways',
memberName: 'giveaway',
aliases: ['ga'],
description: 'Fa partire l\'estrazione di un premio',
userPermissions: ['ADMINISTRATOR']
})
}
async run(message, args) {
if(isNaN(args) || !args) {
message.reply('Devi passare un numero come parametro es. `jsga 1`');
return
}
message.delete();
const time = args * 60000;
const timezoneOptions = {
hour: 'numeric',
minute: 'numeric',
hour12: false,
timeZone: 'Europe/Rome'
};

const endingTime = new Intl.DateTimeFormat('it-IT', timezoneOptions)
.format(addMilliseconds(new Date(), time));

const endGiveaway = (msg) => {
setTimeout(() => {
const participants = [...msg.reactions.cache.first().users.cache.values()];
const humans = participants.filter(participant => !participant.bot);

if(humans.length) {
const winnerId = humans[Math.floor(Math.random() * humans.length)].id;
message.channel.send(`🎉 **Il vincitore del ${embedTitle} è <@${winnerId}>** 🎉`);
} else {
message.channel.send(`😕 **Non ci sono vincitori per il ${embedTitle} perché nessuno ha partecipato all'estrazione (o forse ho un bug 🤔)**`);
}

msg.edit(giveawayEnded);

}, time)
}

const embedColor = '#ffe000';
const embedTitle = 'Jetbrains giveaway';
const embedURL = 'https://www.jetbrains.com/store/redeem/';
const embedThumbnail = 'https://italiajs-media.firebaseapp.com/images/jetbrains.png';
const embedDescription = `**Free Personal Subscription \n100% DISCOUNT CODE** \n\nAppCode, CLion, DataGrip, GoLand, IntelliJ IDEA Ultimate, PhpStorm, PyCharm, ReSharper, ReSharper C++, Rider, RubyMine, WebStorm, o dotUltimate \n\n\n`;
const embedDescription = '**Free Personal Subscription \n100% DISCOUNT CODE** \n\nAppCode, CLion, DataGrip, GoLand, IntelliJ IDEA Ultimate, PhpStorm, PyCharm, ReSharper, ReSharper C++, Rider, RubyMine, WebStorm, o dotUltimate \n\n\n';
const cta = `👇 clicca per partecipare all'estrazione. **(termina alle ${endingTime})**`;
const ended = '**🛑 Il giveaway è terminato!** 🛑';

const giveawayStarted = new MessageEmbed()
const giveawayStarted = new EmbedBuilder()
.setColor(embedColor)
.setTitle(embedTitle)
.setURL(embedURL)
.setThumbnail(embedThumbnail)
.setDescription(embedDescription + cta);

const giveawayEnded = new MessageEmbed()
const giveawayEnded = new EmbedBuilder()
.setColor(embedColor)
.setTitle(embedTitle)
.setURL(embedURL)
.setThumbnail(embedThumbnail)
.setDescription(embedDescription + ended);

const msg = await message.channel.send(giveawayStarted);
await interaction.deferReply();

const msg = await interaction.channel.send({ embeds: [giveawayStarted] });
await msg.react('🎁');
endGiveaway(msg);

await interaction.editReply(`Giveaway avviato! Durata: ${minutes} minuti`);

setTimeout(async () => {
const fetchedMsg = await msg.fetch();
const reaction = fetchedMsg.reactions.cache.get('🎁');

const users = await reaction.users.fetch();
const participants = users.filter(user => !user.bot);

if (participants.size > 0) {
const winner = participants.random();
await interaction.channel.send(`🎉 **Il vincitore del ${embedTitle} è <@${winner.id}>** 🎉`);
} else {
await interaction.channel.send(`😕 **Non ci sono vincitori per il ${embedTitle} perché nessuno ha partecipato all'estrazione (o forse ho un bug 🤔)**`);
}

await msg.edit({ embeds: [giveawayEnded] });
}, time);
}
}
};
23 changes: 9 additions & 14 deletions commands/info/help.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
const Commando = require('discord.js-commando');
const { SlashCommandBuilder } = require('discord.js');

module.exports = class HelpCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'help',
group: 'info',
memberName: 'help',
description: 'Restituisce la lista dei comandi disponibili'
})
}
async run(message) {
message.channel.send('pls send help!!!');
message.react('😱');
module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Restituisce la lista dei comandi disponibili'),

async execute(interaction) {
await interaction.reply('pls send help!!!');
}
}
};
27 changes: 10 additions & 17 deletions commands/info/info.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
const { MessageEmbed } = require('discord.js');
const Commando = require('discord.js-commando');
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');

module.exports = class InfoCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'info',
group: 'info',
memberName: 'info',
description: 'Restituisce delle informazioni su questo bot'
})
}
module.exports = {
data: new SlashCommandBuilder()
.setName('info')
.setDescription('Restituisce delle informazioni su questo bot'),

async run (message) {
const embed = new MessageEmbed()
async execute(interaction) {
const embed = new EmbedBuilder()
.setColor('#ffe000')
.setTitle('🤖 Vanilla - il bot di Italia JS')
.setDescription(`Vanilla è un bot nato con l'idea di essere sviluppato dai membri della community ed è stato creato in node con [Discord.js](https://discord.js.org).
Expand All @@ -23,9 +17,8 @@ module.exports = class InfoCommand extends Commando.Command {
Sviluppare comandi per Vanilla è divertente e può essere un modo per avvicinarsi all'open source.

Aspetto i tuoi contributi! 🦾
`)
`);

message.channel.send(embed);
console.log()
await interaction.reply({ embeds: [embed] });
}
}
};
79 changes: 43 additions & 36 deletions commands/voting/suggest.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
const { MessageEmbed } = require('discord.js');
const Commando = require('discord.js-commando');
const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require('discord.js');

Check warning on line 1 in commands/voting/suggest.js

View workflow job for this annotation

GitHub Actions / Build / build (22.x)

'ChannelType' is assigned a value but never used
const { suggestionChannel } = require('../../config.json');

module.exports = class SuggestCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'suggest',
group: 'voting',
memberName: 'suggest',
aliases: ['plz'],
description: 'Pubblica un messaggio con un\'idea o un suggerimento che può essere votato dagli utenti'
})
}

async run (message, args) {
module.exports = {
data: new SlashCommandBuilder()
.setName('suggest')
.setDescription('Pubblica un\'idea o un suggerimento che può essere votato dagli utenti')
.addStringOption(option =>
option.setName('suggerimento')
.setDescription('Il tuo suggerimento')
.setRequired(true)),

if(message.channel.type === 'dm') {
message.channel
.send(`Questo comando non è utilizzabile nei messaggi diretti`);
return
async execute(interaction) {
if (!interaction.guild) {
return await interaction.reply({
content: 'Questo comando non è utilizzabile nei messaggi diretti',
ephemeral: true
});
}

if(message.channel.name !== suggestionChannel) {
const channelId = message.guild.channels.cache.find(channel => channel.name === suggestionChannel);
message.channel
.send(`Questo comando è utilizzabile solo nel canale ${channelId}`);
return
const targetChannel = interaction.guild.channels.cache.find(channel => channel.name === suggestionChannel);
if (!targetChannel) {
return await interaction.reply({
content: 'Non riesco a trovare il canale per i suggerimenti',
ephemeral: true
});
}

if(!args) {
const cmdError = await message.channel
.send('Utilizzo: `jssuggest <il mio suggerimento>`');
await message.delete();
return await cmdError.delete({timeout: 10000})
if (interaction.channel.id !== targetChannel.id) {
return await interaction.reply({
content: `Questo comando è utilizzabile solo nel canale ${targetChannel}`,
ephemeral: true
});
}
const embed = new MessageEmbed()

const suggestion = interaction.options.getString('suggerimento');

const embed = new EmbedBuilder()
.setColor('#ffe000')
.setAuthor(message.author.username, message.author.avatarURL())
.setDescription(args)
.setFooter('💡 Stato: in valutazione')
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL()
})
.setDescription(suggestion)
.setFooter({ text: '💡 Stato: in valutazione' });

message.delete()
const msg = await interaction.channel.send({ embeds: [embed] });
await msg.react('👍');

const msg = await message.channel.send(embed);
await msg.react('👍')
await interaction.reply({
content: 'Suggerimento pubblicato!',
ephemeral: true
});
}
}
};
Loading