#development
1 messages Β· Page 439 of 1
Also it's send yeah
How to make list of user permissions with discord.js?
who can help me with enmap?
I sometimes getting "key does not exist" but only sometimes on diffrend guilds
current code : ```js
var embed = new Discord.RichEmbed()
.setAuthor('user info : ', message.author.avatarURL)
.setTitle("Username : ")
.addField("Roles", message.member.roles.map(role => role.name).join(", "))
.addField("Join date", message.member.joinedAt)
.addField("Nickname", message.member.nickname)
.addField("Last Message", message.member.lastMessage)
.addField("Permissions", message.member.permissions.raw)
.setDescription(message.author.username)
.setThumbnail(message.author.avatarURL);
message.author.send({embed});
it doesn't list permissions correctly, can anyone help? π€
https://hastebin.com/iqimunufex.py
The file modlog.json gets purged every time someone is kicked
does sqlite3 raise any errors when no data is selected with SELECT?
One message removed from a suspended account.
One message removed from a suspended account.
you already defined commandfile
One message removed from a suspended account.
you must have let commandfile = bot.commands.get(cmd.slice(prefix.length)) twice in your code
check
One message removed from a suspended account.
One message removed from a suspended account.
you can only have it once
remove the first two lines
var embed = new Discord.RichEmbed()
.setAuthor('user info : ', message.author.avatarURL)
.setTitle("Username : ")
.addField("Roles", message.member.roles.map(role => role.name).join(", "))
.addField("Join date", message.member.joinedAt)
.addField("Nickname", message.member.nickname)
.addField("Last Message", message.member.lastMessage)
.addField("Permissions", message.member.permissions.raw)
.setDescription(message.author.username)
.setThumbnail(message.author.avatarURL);
message.author.send({embed});
``` it doesn't lists user permissions π€
One message removed from a suspended account.
yo i heard someone wants free hosting
One message removed from a suspended account.
One message removed from a suspended account.
@abstract mango here https://gist.github.com/SolarysDev/842146436fe155577873188de8e416d0
how to give someone a role discord.js
guildMember.addRole(<id or role>)
@knotty steeple
make sure to check for manage roles perm first
you give me an indea for the name of my bot?
how about The Big Gay
How to make a hyperlink?
I'm trying to make it so when someone gets banned/kicked they would get a message by the bot saying that you have been banned/kicked
wait no
you need msg.author.sendMessage
but, i want it so it would send it the message to that person
node js right?
yes
that is not js
π€
it is
await message.author.sendMessage('message')
nah
I mean what he wrote
i dont use "message" i use "msg"
yes
@supple owl
kickuser (you have that already, u need it to kick)
kickuser.send("Kicked for gay");
could i put in args into the message?...
someone approves or declines my bot? without haste eh ..
ok, thanks everyone
let gay= client.users.get("196214245770133504"); gay.send("ey");
like this
you dont need the first line if you have the user already
it can't send the message to someone that isn't in the server, make sure to send the dm first before kicking
@onyx summit i suggest you fix your commands and check them through
your bot sent NSFW content through your meme command in a non-NSFW marked channel
ur bot bout to get a delete if you dont fix this issue now
it was literally just a mosaic of porn
OH saw that one but did only looked over it an thought okay what is that shitty post
idc what it was or how it happened, prevent it, disable the command, remove it completely idc
Lmao
Lets say you make a file called utils.js, all functions start with modules.export. Lets say you make 2 functions, one called hello and the other called hi. How do you call hello in hi in utils.js.
^
TypeError: Cannot read property 'addRole' of null
at Request._callback (/home/ubuntu/bot/commands/ROTMGcommands/verify.js:560:48)
at Request.self.callback (/home/ubuntu/bot/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/home/ubuntu/bot/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/home/ubuntu/bot/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
error: Forever detected script exited with code: 1
error: Script restart attempt #1
``` why do i get this error?
@shy verge ok thanks, @earnest phoenix when you're free look into https://gist.github.com/SolarysDev/842146436fe155577873188de8e416d0
how can i check if the author is a webhook ?
@inner jewel do you know?
but isent a webhook a part of a bot or?
It may just show as a bot, debug your code and check for any differences
its weird since it happens random
What happens random?
Idk if a webhook shows as a bot or not.. get an IDE.. VSCode or something and debug
let role = message.guild.roles.find("name", config.guildsetting.memberRoleName);
if(!role) return;
message.member.addRole(role).catch(error => {});
message.member.setNickname(data.name);
};```
thats the code
but should not the catch error cancel it?
No
Im not sure with JS. But the code would continue, and error at setNickname aswell
Since webhook is not a member
What if you add.. if (!message.author) return;
idk but i can try and see if theres come there is a error
I havent done a ton of debugging with webhooks and definitenly none in JS
yea i dont know webhooks at all
Could be a hierarchy issue
Maybe webhook == server owner, so you cant setNickname
no its not the server author
i log a lot of things and its just a random person that triggers it
so im like wtf
its so random aswell
Youre getting random webhooks?
idk
like the command just crashes randomly and fucks the bot up
this is a another thing https://gyazo.com/0075fb1bb1d0e4b049de6928cb1ab553
why does it remove the roles? i have no member.removeRole() in my code
Are you subscribing to the RoleRemoved event, or whatever it may be called?
Your bot is the only bot in your testing server?
Just wondering if someone else removes a role and your bot detects it
no dyno is in it as well its that one logging it
but no one in the server is removing roles talked to all the mods
You can check your audit log
audit logs?
It will show who did it
Server settings
good idea i will check it now
@fleet mason just check if member or guild is null return
or actually just member
on dms member is null as well
so if (!message.member) return;
lol ok so i checked the audit log but i cant fin any log with removing the role... and yes the bot removes the role because it adds but the role dosent get added and its in the audit log that it adds the role π
hi i am trying to code my first bot, i downloaded visual studo and am following a youtube tutorial but i seem to be missing something from my installation package
the code i am copying is not finding the object it is calling for
using Discord;
using Discord.Commands;
it cant find discordclient
why not use a codeblock
sorry its been a long time since i coded anything what are you suggesting?
what's the error
```
your code here
```
your code here
` class MyBot
{
DiscordClient discord;
public MyBot()
{
discord = new DiscordClient(x =>
{
x.loglevel = LogSeverity.Info;
x.Loghandler = Log;
});
}
private void Log(object sender, LogMessageEventArgs e)
{
Console.WriteLine(e.message);
}
}`
error please
it cant find the class DIscordclient
your tutorial is outdated
Tutorial series about making a Discord bot in C# .NET. Having a problem? Join our Discord and ask: https://discord.gg/R9j8DJF
i figured. can someone point me to an updated one or tell me the correct class
thanks
bbl π
const commands = {
'ping': (msg) => {
msg.channel.send('pong');
}
};
client.on('message', msg => {
if (msg.content.startsWith(tokens.prefix + 'ping')) {
commands['ping'](msg);
}
});
``` I'm trying to add "aliases" to my bot but I'm not sure how I would go about doing that.
@fleet mason is it possible someone has your webhook url and is using it?
@radiant hatch not sure this works in JS but I would create an array of acceptable triggers for each command and check the given keyword against these keywords in your command handler
thats a weird setup too
@solemn valve do you actually have the discord libs installed?
eh, it was the first that came to me
@mental solstice his usings would error if he didn't
but he is using the lib namespaces without error, so the lib is correct
problem is that he's using the wrong ones
and 1.0 forward it's DiscordSocketClient now
@mental solstice yes Discord.net discord.net.commands and discord.net.core
Yeah, try renaming to DiscordSocketClient
ok
im gonna watch the updated tutorial
so i ask as few unnecessary questions as possible π
do you know c#
If he did.. VS would recommend he import WebSocket.. but yes.. learn c#
like at all
i used to code in C++ and JS
like a long time ago
conceptually it doesnt look so different i just have to go slow and reacclimative
acclimatize
actually i used to code in delphi
prob noone here even knows what that is
π
ill start over and watch this tutorial and then be back
so i have this code
if (user.highestRole >= msg.member.highestRole) return msg.reply('the user your trying to kick has an equal or higher role than you.');
``` it should prevent users being kicked if they have an equal or higher role to the user their trying to kick. but its preventing me from kicking any users, even if they have a lower role
uh i dunno
the new tutorial tells me to create the project using .net framework and i only.see .net core
back to the installer?
TypeError: fn.bind is not a function ?
there is https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=highestRole @mental solstice
im just trying to eval msg.guild.channels.find('name', 'mod-log')
ugh the installer doesnt want to work, says cant install to a non empty directory
do i have to do the whole thing over again?
nvm
discord.js
ok i need to install .net workload somehow i didnt
Nevermind just read docs
do i need to uninstall studio? when i try to add the workload it wont add it to the current directly
Not sure nzranger.. all the .net stuff should have been default with installer
not sure if i install a new instance of studio with just .net that will work
ok then how do i find a channel in a guild
ok im just gonna blow away the old version and redo it all to be safe
Vs2017
msg.guild.channels.get("channel_id");
or that π
Can someone help me with something? I'm using the module canvas-constructor to manipulate some images. So far what I'm doing is load one image file using fs.readFile("./path") and it seems to be working fine until I try to edit the canvas by adding a image on top of it with the same width and height then trying to save it using fs.writeFile("./path", image, function(err)... . So far Fs is saving the picture to my root folder as expected but when I open up the jpg file it doesn't have anything in it, what am I doing wrong?
Btw canvas is installed and working
I've tried to draw rectangles and add text using canvas-construct and it works fine
When I view the picture it displays stuff correctly
But adding images to the canvas isn't working
@shy verge Do you have to have my token when you are hosting?
Not neccesarily, but as he probably has root access over the VPS, he could read it if he wants to
I configure all home directories to be only readable by their user. I only ever use root to delete users who violate the agreement in the gist.
I won't ever take a peek, and neither can anyone else.
yes
Do I name the file .env .gitignore or something?
no
Whatever works, I simply clone the repo into your home directory during intitial setup.
no wait that's for you to do nvm
and other ignores
All I do is install necessary runtimes and set up your permissions, the rest is all up to you.
So inside a file called .gitignore I put ```
.env
TOKEN=NOSEEINGTHISREEE
no
oof
you don't put token in your .gitignore
just the file names for files that shouldn't be added to git
Oh
You put your token in the .env
sounds good
@shy verge What the heck happened to github
MS bought it
Now it sucks
no
I made a repo and I need to do something?
SqliteError: UNIQUE constraint failed what does this mean?
Wait what
it means "lol what how did you get this error"
@earnest phoenix commit your stuff to the GitHub repo
just use git
I used to be able to just commit files
oh
that's quite inefficient, just commit with git cli
when making repo- do that ^
And drop upload it if you mean that kind of upload
Does anyone have experience with pyttanko?
anyone using aiohttp & has experience with upvote rewards please contact me. I'm desperate ;-;
is there a list of the region names provided by msg.guild.region for devs?
the raw ones like sydney
@grizzled totem from /voice/regions https://hastebin.com/irarahasog.json
thanks
i did find that on the discord dev docs but dunno how to use it so thanks π
discord had a london voice region π€
Anyone having api errors 
(node:1861) UnhandledPromiseRejectionWarning: DiscordAPIError
at item.request.gen.end (/app/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:71:65)
at then (/app/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
(node:1861) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:1861) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Resetting token causes them to go away but bot doesn't login
ok it is resetting everytime I refresh the page
lol on my bot i just made this my help menu
***Note*** *Make Sure to Use Prefix Before all Commands*\n**ββββββββββββββββββββ**\n**help** `<Lists All Help Commands>`\n**ββββββββββββββββββββ**\n__**Fun Commands:**__\n\n**battle** `<A Battlegrounds Minigame>`\n**rr** `<Russian roulette>`\n**gamble** `<A Money Gambleing Command>`\n**google** `<A Google Source>`\n**maps** `<Mapping system>`\n**weather** `<Check the weather at your location>`\n**translate** `<translater>`\n**userinfo** `<Shows info about a user>`\n**roll** `<rolls the dice>`\n**ββββββββββββββββββββ**\n__**Informational Commands**__\n\n**bot-owner** `<shows bot owner info>`\n**ping** `<shows bots ping>`\n**ββββββββββββββββββββ**\n**__Admin Commands__**\n\n**say** `<says a message>`\n**purge** `<clears messages>`\n**setprefix** `<changes the bots prefix>`\n**ββββββββββββββββββββ**
@night imp do you have a .catch() function.. to handle the unhandled promiserejection?
ok ive installed studio again, following tutorial, made .net framework console app project done a few small things, get to the second line of code and bam, "var" is not recognized
what am i missing now
`using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO;
namespace translate2
{
class Utilities
{
string json = File.ReadAllText("SystemLang/alerts.json");
var
}
}`
string is fine isnt it from the same library
You canβt just put βvarβ. Thatβs invalid syntax.
i was trying to define a variable as type var
it doesnt recognise the class
and now it does and i didnt touch anything
π
something is weird
Is this C++?
C#
Okay. Iβm a bit more familiar with that.
now its undefined again
Are you getting any specific output?
What is the error exactly?
Welcome to Visual Studio Code
if im missing a datatype im missing a library
or is this just whackl
i said it turned blue for a second
In my experience with VS Code, it randomly gives me errors and sometimes doesnβt. If it compiles, youβre good and ignore it.
Well, make something that should compile. Then run it. If it errors, then we have an issue.
ok
@solemn valve just donβt use var then and use the type directly instead
compiled
moving on next tutorial
i feel like im back in kindergarten again
π
lol this guy is all over the place
i have a bot online in my server π
better not be javascript 
i have a bot written in c# but i want to use this api
is that possible
im trying to make a translator
i just got the bot running and online on my server and it recognizes commands
@earnest phoenix
π

@keen drift I have 2 repot u 2 polik 4 buly
internet police is on my side 
oof
Oi
Just because I don't have Discord Nitro doesn't mean you have to keep using that emoji
im here
kk

Try this @solemn valve
using UnityEngine;
using System.Collections;
public class MYCLASSNAME : MonoBehaviour {
const translate = require('google-translate-api');
translate('Ik spreek Engels', {to: 'en'}).then(res => {
console.log(res.text);
//=> I speak English
console.log(res.from.language.iso);
//=> nl
}).catch(err => {
console.error(err);
});
}
that's
Just for testing
oh
It's rather hard to interface between languages
Why don't you help him then
IPC works though
can i use that api from c#?
I'm sure there's one in Csharp
or do i have to make a bot in js
Oi
this one is .net C#
Thats the one I was about to post
``
using RavSoft.GoogleTranslator;
Translator t = new GoogleTranslator();
string translation = t.Translate ("Hello, how are you?", "English", "French");
Console.WriteLine (translation);
Console.WriteLine ("Translated in " + t.TranslationTime.TotalMilliseconds + " mSec");
Console.WriteLine ("Translated speech = " + t.TranslationSpeechUrl);
Wait
You can also query this endpoint http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}
How does C# catch messages?
catch what message
in the discord api?
Csharp has event listeners
So just like js?
not exactly
what
I finally left glitch
Now I get free hosting
-_-
Solarys does free hosting
to be fair glitch isn't that bad for small test stuff
but actual vps always better
idk what solarys is
@ Solarys
he is a person
I'm not pinging him
He did a giveaway for free hosting iirc
the fidget spinner?
yes
oh kek
kek kek
He still does, it seems
my vps cost is not that bad, patreon pays for all of it atm
Lol
And I think we should move to #memes-and-media, no?
Fishy
I am cheap
I pay for the smallest amount I can
@keen drift Whats ur bot
Β―_(γ)_/Β―
My bot is on a $3/mon vps and it runs just fine, doesn't need anymore
@coarse carbon 
@night imp Yeah my is about $3.50
No need to buy extra power for an engine that uses half of it
Mine is about free
So, my message got ignored. Shouldn't this be in #memes-and-media?
This is about bot development but I guess we could
Try querying http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}
sorry i need it dumbed down a little more than that
i mean maunally that brings to me a webpage
no i figured that i dont know how to call a website from inside c# yet and if im hard calling a website i need to understand the parameters
and how to call one
π
why u pinging me with that
I pinged u about the thing above it
User not found
so that package i posted is only for js ? i cant call it from c#?
yes
@earnest phoenix what lib?
client.user.setActivity(`text here`, { type: 3 });
K thanks
0 is playing, 3 is watching, can't remember the other two
kk thanks
@solemn valve You can, but you don't want to
ok
ill try some of these other packages. how do i tell if they are c# and where is the documentation?
im using visual studio
so all langs i assume are showing up
that node.js package is here for example
not that i can tell. some have stuff in the description but it doesnt seem like i can search for only c# packages
@grizzled totem what lib
discord.js
<User>.presence.status
i figured that but how do i show a custom emoji based on it?
if (theStatus === 'online') { /** show online emoji **/ }
like if (user.presence.status === 'online') { msg.channel.send(onlineEmoji); } this but more compact and for all of them
use switch then
can i make a seperate class in js that does all the interaction with the API i was shown and then call it from C#?
@solemn valve Yeah with IPC, which is not fun to work with as they have limitations
but its just a string in and string out right?
it's not going to be simple as function calls
ok
ok
IPC you need to listen for the messages on both side, process them and then send back, then process it to figure out what function called it
then callback to that function
π
so either stick with C# all the way
or switch to js for everything
like I said there's an URL you can prob call to
u just have to learn how in Csharp
make use of it
can't imagine there's a package for simple stuff like this
ok
so now i just need to find out how to make a web call and receive a response in the form of a file, read it and write it
pretty much
anyone know what is happening here? The bot decided to kill itself somehow while I was inactive.
no idea, you should prob catch all your promises
hmm
@client.event
async def on_member_join(member):
embed = discord.Embed(colour=0x318CE7)
guild = member.guild
await client.send(member, "content")
embed.add_field(name="content", value=guild.name, inline=True)
embed.add_field(name="content", value=guild.id, inline=True)
embed.add_field(name="content", value=guild.created_at, inline=True)
embed.add_field(name="content", value=guild.region, inline=True)
embed.add_field(name="content", value=guild.owner, inline=True)
embed.add_field(name="content" value=guild.member_count, inline=True)
embed.set_author(name="content"+guild.name)```
```py
AttributeError: 'Client' object has no attribute 'send'
``` π€
0 = playing, 1 = streaming, 2 = listening, 3 = watching
thanks π
Anyone know a way to get the last commit date of this json from github to display it on a website ? js/jquery
https://api.github.com/repos/discordapp/discord-api-docs/commits?path=docs/Change_Log.md
@earnest phoenix async or rewrite?
@vernal sorrel talking to me ? π€ Wouldn't know how to put it in js/jquery either way
yeah
yea my experience in this area is fairly low
what will happen if I will try to update a non-existant data with sqlite3?
@slender thistle rewrite
member.send then
umm probably better to do:python if not user.dmchannel: await user.create_dm() await user.dmchannel.send(message)
I've asked this question about a week ago, but i still cant seem to work it out. basically i have an ask command, which anyone can use to ask a question to a server staff member about anything, and a setup command, which only an administrator can use, and all it does it set the channel that the questions will be asked in.
for the setup command, it's gonna be /AJ/setup <#channel>
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Discord;
using Discord.Commands;
namespace AssistantJoe.Core.Commands
{
public class Setup : ModuleBase<SocketCommandContext>
{
[RequireUserPermission(GuildPermission.Administrator)]
[Command("setup" + Context.Client.GetChannel)]
public async Task HelpAsync()
{
EmbedBuilder embed = new EmbedBuilder();
embed.WithTitle("Command Coming Soon!");
embed.WithDescription("");
embed.WithFooter($"{DateTime.Now}");
embed.WithColor(Color.DarkBlue);
await ReplyAsync("", false, embed.Build());
}
}
}
its the + Context.Client.GetChannel
ik
dont do it like that, take the Channel as argument of the Command
im trying to figure out how to make it to set the channel
Then take the Channel as the argument.
instead doing [Command("setup" + somearg)] do public async Task HelpAsync(SocketChannel channel)
ok
this will take a SocketChannel as argument
show the code now pls
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
namespace AssistantJoe.Core.Commands
{
public class Setup : ModuleBase<SocketCommandContext>
{
[RequireUserPermission(GuildPermission.Administrator)]
[Command("setup")]
public async Task HelpAsync(SocketChannel channel)
{
EmbedBuilder embed = new EmbedBuilder();
embed.WithTitle("Alright! You are set up!");
embed.WithDescription("All questions will be posted in " + Context.C);
embed.WithFooter($"{DateTime.Now}");
embed.WithColor(Color.DarkBlue);
await ReplyAsync("", false, embed.Build());
}
}
}
wait i found it i think
Context.C isn't a thing
yeah i just realized
You should use channel
i havent finished that part yet
SocketChannel channel
this is the reference to the channel
as an argument
instead of Context.C use channel.name
i didnt realized until i pasted the code that i didnt finish whatever i was gonna out as Context.C
now, i don't know what language you are coding in, nor the framework you are using, but this should be implemented
C#
mhm
no, it will interpret off as a channel, and most likely cause an error
Oh
Can someone tell me a method to detect nsfw content (free, I dont have money) Idk if its an api or lib
if you want, you can interpret the channel as a string, then get the channel using the string, and if the string == 'off' then do some code
@simple bramble
ok
idk how to do it in C# (not that i don't know C#, because i do know C#, but because i haven't worked with the discord api for C#)
ok
ask someone else on the server (that uses the C# api obviously) and maybe they can help you
ok
please don't expect to be spoonfed on this server
ik
He had some issues with the setup command
yeah
Now he's figuring out how to get a channel from a string
(and idk how to do that since i'm not working with the discord C# API)
i figured out how to setup the channel, but now i want it to be able to be turned off (by an administrator ofc)
Using a db i assume?
he means by prefix!setup off
Ok well u will need a stored boolean so it doesnt change when you restart your code
ok
Doesnt have to be boolean, could be a string, on or off.. whatever you prefer
Yeah less room for human error.. so, someone sets up their channel, then turns setup off?
yeah, if they want to turn it off
Essentially, when setup is initiated, all stats for that server are stored.. askChannel(even if null, easier to change if it exists in the DB table), Setup(true or false).. etc
In the table with the server its connected to
ok
What all do you need stored? Guild ID, AskChannel ID, and Setup?
yeah, thats all
So best to have a command that stores all those, however u choose to start it
Is that with the setup command?
yes, with the setup comman
When they set up..INSERT INTO sqlTable.. Context.Guild.Id, argumentAskChannelName, SetupTrue
Something along those lines
yeah
To turn setup off, you would simply query the db to change the boolean value WHERE GuildId = Context.Guild.Id
ok
Then if someone types setup command, retrieve the value of the Setup boolean, and if true, let them set up, if false tell them to piss off
yeah, and if they turn it back on, then they would just /AJ/setup <#channel>
Ok, and that is the ask channel?
yes
await client.change_presence(activity=discord.Activity(type=ActivityType.streaming, url='https://www.twitch.tv/bot', name="?help /|\ Cloudy"))```
`module 'discord' has no attribute 'Activity'`
π
?
So what in the discord aspect do you need help with? Most of your code will be db queries
@mental solstice i got a bot online and taking commands π
can somone point me to a C# .net framework tutorial for calling a url and doing something with the return
yeah with http
but finding an actual tutorial for it is pretty hard to find. when you google anything like that it returns mostly results for creating webpages in asp.net
maybe help me define what i am searching for better
Yeah it took me a while to find stuff for http requests. SOF will be your best bet, i cant really say there is a good tutorial ive found
@solar vigil message = message.lower()
Just HttpClient, adding headers and getting responses
AttributeError: 'Message' object has no attribute 'lower'
hm
msg = message.content.lower()
Also, can you tell a function to await itself?
'Cause I'm writing with just the discordpy library
async def function()
yeah
then await function()
Is there any way to automate that second await though?
Afaik, there is no way to make the function await itself
nope
Oh well.
what would be the best way to return a list rather than a tuple when trying to fetchall() the data via sqlite3?
or any type of fetching data that I'm not aware of
list(cursor.fetchall())
Yes
async def is_command(command):
if message.content.startswith(prefix+command):
return True
Having a problem
in that it wants to be awaited
can I define it without asyinc?
no
Apparently I can
sometimes I should just try things before asking.
I pressed ctrl+s after writing that.
so that basically forces it to fetch as a list, just like you would force a string with str()?
Yes
good to know
@solemn valve i responded above, i have a couple examples i was working with not long ago
When i get to pc, i can help you out with sending a request.. and if youre gonna be getting into this sort of stuff, i recommend getting Postman
Yeah, something along the lines of c# post request httpclient
With discord.ext, how do I bot.say to a specific channel, by ID?
async or rewrite?
Ah.
@mental solstice does this look right so far?
I use async.
`public class Translate : ModuleBase<SocketCommandContext>
{
HttpClient _client;
[Command("tr")]
public async Task Tr([Remainder]string message)
{
await Context.Channel.SendMessageAsync(GetWebTranslate(message));
}
private async Task GetWebTranslate(string message)
{
}
}`
@solar vigil await bot.send_message(channel, "My stuff")
and then code the http client stuff inside GetWebtranslate using _client
@slender thistle
How do you do it with an ID?
- take a call from user: bot.tr russian test
- send string to webpage api
- read return file
- output to channel its called from
i have #1 and #4 completed
Isn't everything in async under client
So write a method to get the request.. pass in the string to translate in an argument. Then you will have to do the request. Would be much cleaner to write a specific method for it, so its reusable. Unless the api has a c# lib.. idk what getwebtranslate is
thats my function
im asking if the structure is right
its passing a string to a specific method π
the class translate will be created only when tr command is used correct?
well you have something off, you pass a Task what is resolving with nothing to SendMessageAsync
yeah i know its empty at the moment
you should pass a string instead or an awaited Task what resolves with a string
its going to resolve to a strong
It wont be a command and it will return a string probably..
So when someone uses the command !translate
It will call an outside method, to return the string that will be your message
thats what im doing isnt it
im calling getwebstranslate when the tr command is used
and getwebtranslate will use the instance of httpclient called _client
to make the call
resolving in a string passed back
Oh.. yeah i read that wrong. Yikes, i stopped after i read the [Command ()]
Didnt even notice u put another method below the command call
Lol use 3 `
ok
Instead of 1 when encapsulating code on here
now i need to write getwebtranslate() which will use the _client i defined when the class was created, correct?
But yes, use _client to get the call.. there are ways of adding headers, if required
Yeah
that will create a new instance of httpclient everytime tr is called thats correct?
Oh. U will need a return in your method
sure
Public async String
I havent done async Task before so im not sure how to make that work when returning types
ok just wanted to make sure the logic was correct before i proceeded
thanks
do i need to dispose of the httpclient at the end of the public class or will it happen automatically
Its good practice
Garbage collection does a pretty good job tho
Oh.. no
Since youre creating and instance when the class os created
it will be disposed of when its done right
ok
in sqlite3, rather than getting a list of tuples with fetchall(), is there any way to get a list of objects instead? trying to select a single column, so I think there is a way that I'm not aware of
how do i return a string from a private Task method
private async Task GetWebTranslate(string message)
it defaults to returning a task obect but i can return a different type right
Looks like private async Task <string>
hi i want to make a bot and idk how
Use a search engine
if you don't know how, then you won't be able to
i didnt know how yesterday
That's deep.
I don't like how Python handles file writing.
i just want an emoji to pop up when someone says cat related words thats like,,, basic right?
That's gonna be a lot of or.
Tutorial series about making a Discord bot in C#.NET. Having a problem? Join our Discord and ask: https://discord.gg/R9j8DJF Source Code: https://github.com/...
go to part 1
im going for "cat" or "meow" im a simple person with simple wants
building a bot is as difficult as knowing how to use a programming language, basically @safe kettle
i dont know where to like, go, to submit the bot, i guess??
you already have a bot?
no
follow the tutorial
I don't think video tutorials teach anything at all, people just repeat word for word all the time
what i mean is do i have to program the bot IN DISCORD?
ok so how do i put it. in discord. i guess
again, coding a bot with a programming language, just like you'd code a game
anyone can create a bot application/account on discordapp.com/developers/applications/me
I just looked up Discord Bot API and found that.
I don't know how I've forgotten this
but
how do you use regexes in python if statements?
if string == /regex/?
Python Regular Expressions - Learn Python in simple and easy steps starting from basic to advanced concepts with examples including Python Syntax Object Oriented Language, Methods, Tuples, Tools/Utilities, Exceptions Handling, Sockets, GUI, Extentions, XML Programming.
@mental solstice got the call to the website working with issuccessful = yes π
Congrats.
now ijust need to parse the results π
Is there a way to alias commands, or do I just define commands to call existing ones :?
Nice.. how does it return them? Json.. or
in a file that looks like this
[[["test","γγΉγ",null,null,2]],null,"ja",null,null,null,1,null,[["ja"],null,[1],["ja"]]]
thats not json i dont think
?
or what type of json format is it
@solar vigil Using commands extension?
Yeah.
Also, please don't ping me 'cause it crashes my Discord and I don't feel like trying to fix it right now.
I'll notice the message regardless.
@commands.command(aliases=['alias1', 'alias2'])
@commands.command(aliases = []) <- inside there define a list of aliases as strings
So for
@bot.command()
async def shutdown():
bot.logout()
I could put
@commands.shutdown(aliases = ['halt', 'stop', etc...])
```?
in your case it will just be inside @bot.command()
is that output a Linq query?
Yeah, thats definitely not json.. but if its a string.. just split by ,
for https://discordbots.org/api/bots/424817451293736961/votes (get info of the last 1000 votes for ur bot), is the order of the dict garunteed?
@mental solstice look
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Cache-Control: no-store, must-revalidate, no-cache
Date: Wed, 27 Jun 2018 17:55:46 GMT
Pragma: no-cache
Transfer-Encoding: chunked
Server: HTTP
Server: server
Server: (unknown)
Access-Control-Allow-Origin: *
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Alt-Svc: quic=":443"; ma=2592000; v="43,42,41,39,35"
Content-Type: application/json; charset=UTF-8
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Disposition: attachment; filename="f.txt"
}
so it is json?
it's the header of the http request
content-type says json?
is this c#?
yes
ok the Content-type means what the type of the response body is
yeah thats what we were looking at
this is the file
[[["test","γγΉγ",null,null,2]],null,"ja",null,null,null,1,null,[["ja"],null,[1],["ja"]]]
must be a type of json?
it's a json array
ok ill look for that thanks
the id of this server is 264445053596991498, but i put it on my list of blocked ids for the leveling system and is the only one that does not work
and my head is exploding
because i put other server ids and it works

this one id doesn't work?
yes
and because is not working i tried this:
if(!user.getMutualGuilds().contains(Shard.getStaticJda().getGuildById("264445053596991498"))) {
code here
}
ok new problem
when i go to my browser and put in the url i am calling from my program i get this information in the file:
[[["test","γγΉγ",null,null,2]],null,"ja",null,null,null,1,null,[["ja"],null,[1],["ja"]]]
the output from my program is this
[[["Γ£Ζ β Γ£,ΒΉΓ£Ζ","Γ£Ζβ Γ£βΒΉΓ£ΖΛ",null,null,0]],null,"ro",null,null,null,0.3104077,null,[["ro"],null,[0.3104077],["ro"]]]
make sure the text is encoded correctly because it expects a txt file
when i change it to translate from english to another language the output is correct from both
[[["γγΉγ","test",null,null,2]],null,"en",null,null,null,0.95929444,null,[["en"],null,[0.95929444],["en"]]]
its the same problem all the translators we were using is having and why i started making my own
so now im up to where everyone else was at π
why does it give me back good info when i do it manually but not from the program only when i am translating non english characters to english
Manually via webbrowser?
Check your request headers in browser, and add them to program.. some websites require certain headers
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Cache-Control: no-store, must-revalidate, no-cache
Date: Wed, 27 Jun 2018 18:16:26 GMT
Pragma: no-cache
Transfer-Encoding: chunked
Server: HTTP
Server: server
Server: (unknown)
Access-Control-Allow-Origin: *
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Alt-Svc: quic=":443"; ma=2592000; v="43,42,41,39,35"
Content-Type: application/json; charset=UTF-8
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Disposition: attachment; filename="f.txt"
}
all of those?
sorry for bothering you with no help, but I recommend using codeblocks cause it makes them easier to read for everyone π
none of that was code π
Status code 200.. isnt that the response?
yes
Stupid question
how d'you check who sent the message
that your bot is replying to?
from context object
ctx.message.author is a Member object
@solar vigil Which Library?
Discord.py async
with discord.ext commands
@mental solstice i understand the requesting ones differ but i want to make them the same as the response right?
No
But you need to pass context for that
Request is what the website looks at when you send a request.. most browsers send like 3 default headers, website may add more.
ok, baby this down for me a bit more. how do i look for what it wants, and where do i write them to
Im at work on mobile.. so i wont be much assistance other than telling u what needs to be done π
ha
What webbrowser do u use?
How do you retrieve a user ID from a mention?
Two variables, replace <@ and > with no character
Eh?
I'm trying to create a command to blacklist a user with *blacklist @user and grab the ID from the mention in the command.
String id = mention.replace("<@","").replace(">","");
in java
You could take user: discord.Member as a command argument (parameter in async def blacklist)
And then, user.id would be what you need
How do you make your command handler async>
?
...........................................................
What library
@solemn valve can you see all the network activity etc. Via developer tools in that browser
@real ginkgo
JS.
Ye but do that for the message event
@mental solstice @sullen path says its because its running from windows
y.trans english ΠΊΠΎΠ½ΡΡΠΎΠ»ΡΠ½Π°Ρ ΡΠ°Π±ΠΎΡΠ°
ok no bot here
it's not allowed to speak here
do you want help with something
Anyone need help?
I can't offer much help because I'm a noob, but does anyone need help?
if anyone needs help they will say, and this chat is kind of unrelated 
anyone know where abouts i can get the discordbots.org token, might be right under my nose but im blind ;v
are bots allowed to have Did you mean to use the command <command>?
@onyx summit what is it
i know what is pm2
just what you need help with
smh
@marsh lark go the edit page of one of your bots and scroll down then you can find the token
xD
https://discordbots.org/api/docs or here
So my question was:
I have 2 bots, I want to run both at the same time, also with monitor
So my problem, how to make it restart when it crashes, how to make it restart when a *.js was changed(bearbeitet)
excluded Node_Modules ofc
@sullen path i downloaded vmware now i need to download the Linux OS as well?
@onyx summit oh
or i need a different api
perfect thanks samurai π
you know how to start a bot normally? @onyx summit
yes
@solemn valve you need a linux OS (although I don't think running a bot in a VM is a good idea)
no it wouldnt π€¦
ofc I did it
it restarts every time you save a file
Bot changes my db and pm2 like RESTART
ok so this method is a dead end of rme
for me
i need a different website or figure out why its returning garbage
only from the bot and not when i use my browser
well there is no other way @onyx summit
π€·
back to the headers idea
also when a bot crashes or exits pm2 restarts it 
@knotty steeple Nothing like nodemon ?
I just need nodemon with restart after error (and maybe process optimation)
if the bot had a fatal error that caused it to go down pm2 will restart it
@sullen path can we use your bot while i am working on mine
sure
idk i dont pm2 much but i know basic things


