所以我刚刚进入python和Discord,我想知道是否有可能只删除机器人的消息。我已经有一个有错误的脚本,' list'对象没有属性'频道'
if message.content.startswith('!clearbeta'):
list = ['!8ball', '!uptime', '!meme', '!animated meme', '!weeb', '!cute af', '!coin', '!fun', '!reaction']
await client.delete_message(list)
await client.send_message(message.channel, "Cleared messages")
答案 0 :(得分:1)
如果你read the documentation,我认为这会有所帮助。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post);
mStorage = FirebaseStorage.getInstance().getReference();
mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
mSelectImage = (ImageButton) findViewById(R.id.imageSelect);
mPostTitle =(EditText)findViewById(R.id.titleField);
mPostDesc = (EditText)findViewById(R.id.descField);
mSubmitBtn = (Button)findViewById(R.id.submitBtn);
mProgress = new ProgressDialog(this);
mSelectImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent,GALLERY_REQUEST);
}
});
mSubmitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startposting();
}
});
}
private void startposting() {
mProgress.setMessage("Uploading Post..");
mProgress.show();
final String title_val = mPostTitle.getText().toString().trim();
final String desc_val = mPostDesc.getText().toString().trim();
if(!TextUtils.isEmpty(title_val)&& !TextUtils.isEmpty(desc_val)&& mImageUri!=null){
StorageReference filepath = mStorage.child("Blog_images").child(mImageUri.getLastPathSegment());
filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
@SuppressWarnings("VisibleForTests") Uri downloadUri = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatabase.push();
newPost.child("title").setValue(title_val);
newPost.child("desc").setValue(desc_val);
newPost.child("image").setValue(downloadUri.toString());
mProgress.dismiss();
startActivity(new Intent(PostActivity.this, MainActivity.class));
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
@SuppressWarnings("VisibleForTests") double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
mProgress.setMessage("Uploading " + ((int) progress) + "%...");
mProgress.show();
}
});
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if ( requestCode == GALLERY_REQUEST && resultCode == RESULT_OK ){
mImageUri = data.getData();
mSelectImage.setImageURI(mImageUri);
}
需要一个client.delete_message
对象,而不是字符串列表。同样,Message
需要client.delete_messages
个对象列表。
您可以使用带有Message
谓词的client.purge_from
之类的内容来测试邮件内容是否与列表中的内容匹配。但是,清除端点的限制为<= 2周(即,您无法删除早于此的邮件)。