i used const channel = member.guild.channels.find(ch => ch.name === `welcome`);
code to get simple channel name which says welcome but when the same channel includes emojis 📜welcome📜
how do i find any channel which is inside emoji 📜welcome📜
this or any other emoji.
const channel = member.guild.channels.find(ch => ch.name === `welcome`);
// some code here
channel.send(`See you once again ${member}!`, attachment);
something like this but does not work i tried
const channel = member.guild.channels.find(ch => ch.name === 📜welcome📜);
my server looks like this my server with channel name and emojis
my complete code is like this -
const channel = member.guild.channels.find(ch => ch.name === `welcome`);
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage('./wallpaper.jpg');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
// Slightly smaller text placed above the member's display name
ctx.font = '28px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);
// Add an exclamation point here and below
ctx.font = applyText(canvas, `${member.displayName}!`);
ctx.fillStyle = '#ffffff';
ctx.fillText(`${member.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);
ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(member.user.displayAvatarURL);
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');
channel.send(`Welcome to the server, ${member}!`, attachment);
lets say i need to find levels channel like in above image the emojis will change but the name will be there so how can i do that this is the data i am trying to add EDIT name is welcome but when i add emoji the name changes
'554141970130403338' => TextChannel {
type: 'text',
deleted: false,
id: '554141970130403338',
name: '📜welcome📜',
position: 0,
parentID: '566212268208029697',
permissionOverwrites: Collection [Map] {
'159985870458322944' => [PermissionOverwrites],
'417208237142573056' => [PermissionOverwrites],
'487733104652582920' => [PermissionOverwrites]
},
topic: '',
nsfw: false,
lastMessageID: '628112146806472715',
lastPinTimestamp: null,
rateLimitPerUser: 0,
guild: Guild {
members: [Collection [Map]],
channels: [Circular],
roles: [Collection [Map]],
presences: [Collection [Map]],
deleted: false,
available: true,
id: '417208237142573056',
name: 'ETHYT Gaming',
icon: '081568475c94dd5724dafc2547a0261c',
splash: null,
region: 'india',
memberCount: 86,
large: false,
features: [],
applicationID: null,
afkTimeout: 3600,
afkChannelID: '440842028713115648',
systemChannelID: null,
embedEnabled: undefined,
verificationLevel: 0,
explicitContentFilter: 0,
mfaLevel: 0,
joinedTimestamp: 1557471391163,
defaultMessageNotifications: 'ALL',
ownerID: '348832732647784460',
_rawVoiceStates: [Collection [Map]],
emojis: [Collection [Map]]
},
messages: Collection [Map] { '628112146806472715' => [Message] },
_typing: Map {}
}
when i got the output in notepad i can see the welcome written but what before and after it ?
String.includes()
will be of great use to you. Instead of comparing the whole string, it'll search for your substring anywhere within it.
const channelName = '📜welcome📜';
console.log(channelName.includes('welcome'));