Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set activity and use codey coin emojis #276

Merged
merged 7 commits into from
Aug 12, 2022
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
3 changes: 3 additions & 0 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ container.botPrefix = client.options.defaultPrefix!;
export const startBot = async (): Promise<void> => {
try {
client.on('error', client.logger.error);
client.on('ready', () => {
client.user!.setActivity('CSC | .help');
});

client.login();
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion src/commandDetails/coin/adjust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SapphireMessageResponse
} from '../../codeyCommand';
import { adjustCoinBalanceByUserId, getCoinBalanceByUserId, UserCoinEvent } from '../../components/coin';
import { getCoinEmoji } from '../../components/emojis';

// Adjust coin balance
const coinAdjustExecuteCommand: SapphireMessageExecuteType = async (
Expand Down Expand Up @@ -45,7 +46,8 @@ const coinAdjustExecuteCommand: SapphireMessageExecuteType = async (
// Get new balance
const newBalance = await getCoinBalanceByUserId(user.id);

return `Adjusted ${user.username}'s balance by ${amount} 🪙.\n${user.username} now has ${newBalance} Codey coins 🪙.`;
const COIN = getCoinEmoji();
return `Adjusted ${user.username}'s balance by ${amount} ${COIN}.\n${user.username} now has ${newBalance} Codey coins ${COIN}.`;
};

export const coinAdjustCommandDetails: CodeyCommandDetails = {
Expand Down
3 changes: 2 additions & 1 deletion src/commandDetails/coin/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SapphireMessageResponse
} from '../../codeyCommand';
import { getCoinBalanceByUserId } from '../../components/coin';
import { getCoinEmoji } from '../../components/emojis';

// Get coin balance
const coinBalanceExecuteCommand: SapphireMessageExecuteType = async (
Expand All @@ -16,7 +17,7 @@ const coinBalanceExecuteCommand: SapphireMessageExecuteType = async (
): Promise<SapphireMessageResponse> => {
const balance = await getCoinBalanceByUserId(getUserIdFromMessage(messageFromUser));
// Show coin balance
return `You have ${balance} Codey coins 🪙.`;
return `You have ${balance} Codey coins ${getCoinEmoji()}.`;
};

export const coinBalanceCommandDetails: CodeyCommandDetails = {
Expand Down
3 changes: 2 additions & 1 deletion src/commandDetails/coin/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SapphireMessageResponse
} from '../../codeyCommand';
import { getCoinBalanceByUserId } from '../../components/coin';
import { getCoinEmoji } from '../../components/emojis';

// Check a user's balance
const coinCheckExecuteCommand: SapphireMessageExecuteType = async (
Expand All @@ -21,7 +22,7 @@ const coinCheckExecuteCommand: SapphireMessageExecuteType = async (
// Get coin balance
const balance = await getCoinBalanceByUserId(user.id);
// Show coin balance
return `${user.username} has ${balance} Codey coins 🪙.`;
return `${user.username} has ${balance} Codey coins ${getCoinEmoji()}.`;
};

export const coinCheckCommandDetails: CodeyCommandDetails = {
Expand Down
48 changes: 24 additions & 24 deletions src/commandDetails/coin/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ import {
SapphireMessageExecuteType,
SapphireMessageResponse
} from '../../codeyCommand';
import { getCoinEmoji } from '../../components/emojis';
import { EMBED_COLOUR } from '../../utils/embeds';

// Get information about coin
const infoEmbed = new MessageEmbed()
.setColor(EMBED_COLOUR)
.setTitle('🪙 About Codey Coin 🪙')
.setThumbnail('https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/282/coin_1fa99.png') // Thumbnail, if needed?
.setDescription(`Codey coins are rewarded for being active in CSC's events and discord!`)
.addFields(
{
name: '🪙 How Can I Obtain Codey Coins?',
value: `Earn Codey coins by:
• Participating in CSC events
• Being active on Discord
---Daily bonus - your first message of the day on CSC's Discord will grant some Codey coins
---Activity bonus - your first message of every 5 minutes on CSC's Discord will grant some Codey coins`
},
{
name: '🪙 What Can I Do With Codey Coins?',
value: `Use Codey coins to:
• Play Casino games such as Blackjack
• Buy virtual CSC Swag in the server (more info to come!)`
}
);

const coinInfoExecuteCommand: SapphireMessageExecuteType = async (
_client,
_messageFromUser,
_args
): Promise<SapphireMessageResponse> => {
return infoEmbed;
// Get information about coin
const COIN = getCoinEmoji();
return new MessageEmbed()
.setColor(EMBED_COLOUR)
.setTitle(`${COIN} About Codey Coin ${COIN}`)
.setThumbnail('https://cdn.discordapp.com/emojis/937096777180516453.webp')
.setDescription(`Codey coins are rewarded for being active in CSC's events and discord!`)
.addFields(
{
name: `${COIN} How Can I Obtain Codey Coins?`,
value: `Earn Codey coins by:
• Participating in CSC events
• Being active on Discord
---Daily bonus - your first message of the day on CSC's Discord will grant some Codey coins
---Activity bonus - your first message of every 5 minutes on CSC's Discord will grant some Codey coins`
},
{
name: `${COIN} What Can I Do With Codey Coins?`,
value: `Use Codey coins to:
• Play Casino games such as Blackjack
• Buy virtual CSC Swag in the server (more info to come!)`
}
);
};

export const coinInfoCommandDetails: CodeyCommandDetails = {
Expand Down
5 changes: 3 additions & 2 deletions src/commandDetails/coin/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
UserCoinEntry,
getUserIdCurrentCoinPosition
} from '../../components/coin';
import { getCoinEmoji } from '../../components/emojis';
import { EMBED_COLOUR } from '../../utils/embeds';

// How many people are shown on the leaderboard
Expand All @@ -33,7 +34,7 @@ const getCurrentCoinLeaderboardEmbed = async (
const userCoinEntry = leaderboard[i];
const user = await client.users.fetch(userCoinEntry.user_id);
const userTag = user?.tag ?? '<unknown>';
const userCoinEntryText = `${i + 1}. ${userTag} - ${userCoinEntry.balance} 🪙\n`;
const userCoinEntryText = `${i + 1}. ${userTag} - ${userCoinEntry.balance} ${getCoinEmoji()}\n`;
currentLeaderboardText += userCoinEntryText;
}
const currentLeaderboardEmbed = new MessageEmbed()
Expand All @@ -43,7 +44,7 @@ const getCurrentCoinLeaderboardEmbed = async (

currentLeaderboardEmbed.addFields({
name: 'Your Position',
value: `You are currently **#${currentPosition}** in the leaderboard with ${userBalance} 🪙.`
value: `You are currently **#${currentPosition}** in the leaderboard with ${userBalance} ${getCoinEmoji()}.`
});

return currentLeaderboardEmbed;
Expand Down
3 changes: 2 additions & 1 deletion src/commandDetails/coin/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SapphireMessageExecuteType
} from '../../codeyCommand';
import { getCoinBalanceByUserId, updateCoinBalanceByUserId, UserCoinEvent } from '../../components/coin';
import { getCoinEmoji } from '../../components/emojis';

// Update coin balance of a user
const coinUpdateExecuteCommand: SapphireMessageExecuteType = async (client, messageFromUser, args) => {
Expand Down Expand Up @@ -40,7 +41,7 @@ const coinUpdateExecuteCommand: SapphireMessageExecuteType = async (client, mess
// Get new balance
const newBalance = await getCoinBalanceByUserId(user.id);

return `${user.username} now has ${newBalance} Codey coins 🪙.`;
return `${user.username} now has ${newBalance} Codey coins ${getCoinEmoji()}.`;
};

export const coinUpdateCommandDetails: CodeyCommandDetails = {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/games/blackjack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApplyOptions } from '@sapphire/decorators';
import { Args, Command, CommandOptions, container } from '@sapphire/framework';
import { Collection, ColorResolvable, Message, MessageEmbed, MessageReaction, Snowflake, User } from 'discord.js';
import { adjustCoinBalanceByUserId, getCoinBalanceByUserId, UserCoinEvent } from '../../components/coin';
import { getEmojiByName } from '../../components/emojis';
import { getCoinEmoji, getEmojiByName } from '../../components/emojis';
import {
BlackjackAction,
BlackjackHand,
Expand Down Expand Up @@ -166,7 +166,7 @@ export class BlackjackCommand extends Command {
const embed = new MessageEmbed().setTitle('Blackjack');
embed.setColor(this.getEmbedColourFromGame(game));
// show bet amount and game description
embed.addField(`Bet: ${game.bet} 🪙`, this.getDescriptionFromGame(game));
embed.addField(`Bet: ${game.bet} ${getCoinEmoji()}`, this.getDescriptionFromGame(game));
// show player and dealer value and hands
embed.addField(`Player: ${game.playerValue.join(' or ')}`, this.getHandDisplayString(game.playerCards));
embed.addField(`Dealer: ${game.dealerValue.join(' or ')}`, this.getHandDisplayString(game.dealerCards));
Expand Down
6 changes: 6 additions & 0 deletions src/components/emojis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ export const initEmojis = (): void => {
export const getEmojiByName = (name: string): Emoji | undefined => {
return emojiList[name];
};

export const getCoinEmoji = (): Emoji | string => {
let emoji: Emoji | string = emojiList['codeycoin'];
if (emoji === undefined) emoji = '🪙';
return emoji;
};